<?

//include("../includes/htmlMimeMail.php");
include_once("../include/main.inc.php");
check_session('MyCpanel','index.php');
@extract($_REQUEST);
//connect to database
$table_name="mailer_list";
$table_name1="mass_mail";
$massqry=mysql_query("SELECT * FROM mass_mail where mailerID='$mailer_id' AND status='N' order by mailID asc");

while($massres=mysql_fetch_array($massqry)) {
$row1=getResult($table_name," where mailer_ID='$mailer_id' AND status='I'");
$subject=$row1['mailer_title'];
$mailfrom=$row1['mailer_reply'];
$message=$row1['mailer_code'];
$headers = "From:Couponming.com<$mailfrom> \n";
$headers .= "Reply-To: $mailfrom \r\n";
$headers .= "X-Mailer:PHP v".phpversion()."\r\n";
$headers .= "X-Priority:3\n";
$headers .= "MIME-version:1.0\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
	$email = $massres['email'];	
	
	$count='1';
	echo $message;
	echo $mailfrom;
	mail($email, $subject, $message, $headers);
    if ($count % 3 == 0) {
      sleep(10); // this will wait 5 secs every 5 emails sent, and then continue the while loop
    }
      $count++;
   updateTable($table_name1," status='Y' where email='$email'");  
} 
echo "All Mail Sent";

?>
