<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Mail Merge</title>
</head>

<body>
<?php 
error_reporting(E_ALL);
include "dbconfig.php";
include 'phpmailer/PHPMailerAutoload.php';		
date_default_timezone_set ("Europe/London");

$sql="SELECT email from mailusers"; 
 		//echo $sql;
		$result=mysqli_query($con,$sql);
	    $db=mysqli_fetch_assoc($result);
		
 function send_driver_email($to,$message,$driver_name)
		 {
	   $driver_email=$to;
	   $driver_message=$message;
	   $driver_name='';
		$mail2 = new PHPMailer;
		$mail2->setFrom('info@motivationripple.com', 'Motivation Ripple - Unique Platform');
		$mail2->IsHTML(true);
		$mail2->addAddress($driver_email, $driver_name);
		$mail2->AddCC('jaspinder32@gmail.com', 'Jas');
		
		$mail2->Subject  = 'We Completed 4 Months';
		$mail2->Body     = $driver_message;
		if(!$mail2->send()){
			echo '<h3>Email was not sent</h3>';
			}else{
				echo 'Mail was sent';
		    }
		 }
		    $res=mysqli_query($con,$sql);
			$passenger_message='';
			$driver_message='';
			
			$rowcount=mysqli_num_rows($res);
			
		if($rowcount>0){
		while($driver=mysqli_fetch_assoc($res))
			{
			
			$email=$driver['email'];
			
        $driver_message = '
<p><strong>Dear Reader</strong></p>
<p>With Most Proud and Warm Welcome,</p>
<p> I would like to announce we have completed 4 Months successfully.</p>
<p><strong><em>Time has gone quick and I have to say this week was very positive, energetic and busy month. We have managed to get 7500+ collective views on articles in 4 Months.<br>
Now we have 136 Ripples (subscribers) on our online platform and more ripples are joining us every day. </em></strong></p>
<h3>Now we have video blogging available to everyone and very soon live vide chat and Vlogging will be available via our website - all for free !!</h3>
<h3>When I started this project, I never thought its going to be that much successful since people are busy on their phones and do not find time for writing. I have got a surprise by comments, facebook shares and articles submitted online by our authors, readers, and contributors. <br>
</h3>
<h3>If you have a friend or colleague who is interested to learn how to become author. You can ask them to get in touch with me. Once again Thank You for being part of this journey.<br><hr>
  Jas Brar - Editor - www.motivationripple.com</h3>
  
		 ';
                 $driver_name='Reader';
				 $send_mail=send_driver_email($email,$driver_message,$driver_name);
			
		
		 }//while lopp
		} // if(rowcount>0
	?>	

</body>
</html>
