Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sqlEmailSent =mysql_query("SELECT * FROM tblEmailSent WHERE emailstatus = ''",$conn);
- echo "tblemailsent";
- if($sqlEmailSent)
- {
- while($rsEmailSent = mysql_fetch_array($sqlEmailSent))
- {
- echo "while";
- $smtp_id=$rsEmailSent['smtpid'];
- if ($smtp_id >0)
- {
- $qrySmtp = mysql_query("SELECT * FROM tblSMTP WHERE smtpid =".$smtp_id,$conn );
- $rsSmtp = mysql_fetch_array($qrySmtp);
- echo "smtp_id >0";
- if ($rsSmtp)
- {
- $mail->Host = $rsSmtp["smtpserver"];
- $mail->SMTPAuth = true;
- $mail->Username = $rsSmtp["smtpuser"];
- $mail->Password = $rsSmtp["smtppassword"];
- $mail->Port = $rsSmtp["smtpport"];
- echo "$rsSmtp";
- if ($mail->Port == 465) {
- $mail->SMTPSecure = "ssl";}
- $mail->SetFrom($rsSmtp["smtpuser"], "");
- $mail->AddReplyTo($rsSmtp["emailreplyto"],"");
- $mail->Subject = "";
- $arr_to = array($rsEmailSent['emailto']);
- foreach($arr_to as $email)
- {
- $mail->AddAddress($email['addr'], $email['name']);
- }
- $mail->Body =$rsEmailSent["emailbodyfile"];
- $mail->CharSet = "utf-8";
- $arr_cc =array($rsEmailSent["emailcc"]);
- foreach($arr_cc as $cc){
- $mail->AddCC($cc['addr'], $cc['name']);
- }
- $arr_cc = array($rsEmailSent["emailbcc"]);
- foreach($arr_cc as $cc){
- echo "xxx";
- $mail->AddBCC($cc['addr'], $cc['name']);
- }
- if($rsEmailSent['emailattachfile1'] && file_exists($rsEmailSent['emailattachfile1']))
- $mail->AddAttachment($rsEmailSent['emailattachfile1']);
- if($rsEmailSent['emailattachfile2'] && file_exists($rsEmailSent['emailattachfile2']))
- $mail->AddAttachment($rsEmailSent['emailattachfile2']);
- if($rsEmailSent['emailattachfile3'] && file_exists($rsEmailSent['emailattachfile3']))
- $mail->AddAttachment($rsEmailSent['emailattachfile3']);
- if($mail->Send())
- {
- $status = "ok";
- // first update the SMTP email count
- $sqlUpdate =mysql_query( "update tblSMTP set emailcount=emailcount+1 where smtpid = " .$smtp_id,$conn) ;
- }
- else
- {
- $status = $mail->ErrorInfo;
- }
- $sqlUpdate =mysql_query( " update tblEmailSent set emailstatus = '".$status."' where emailsentid = ".$rsEamilSent['emailsentid'],$conn);
- return $status;
- }// we found the SMTP information
- } // SMTP ID > 0 -- This will process for each record found in the tblEmail Sent
- }// while -- Loop through until all records are processed
- }
Add Comment
Please, Sign In to add comment