Guest User

Untitled

a guest
Jan 22nd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. $sqlEmailSent =mysql_query("SELECT * FROM tblEmailSent WHERE emailstatus = ''",$conn);
  2. echo "tblemailsent";
  3. if($sqlEmailSent)
  4. {
  5. while($rsEmailSent = mysql_fetch_array($sqlEmailSent))
  6.  
  7. {
  8. echo "while";
  9. $smtp_id=$rsEmailSent['smtpid'];
  10.  
  11. if ($smtp_id >0)
  12. {
  13.  
  14. $qrySmtp = mysql_query("SELECT * FROM tblSMTP WHERE smtpid =".$smtp_id,$conn );
  15. $rsSmtp = mysql_fetch_array($qrySmtp);
  16.  
  17. echo "smtp_id >0";
  18. if ($rsSmtp)
  19. {
  20. $mail->Host = $rsSmtp["smtpserver"];
  21. $mail->SMTPAuth = true;
  22. $mail->Username = $rsSmtp["smtpuser"];
  23. $mail->Password = $rsSmtp["smtppassword"];
  24. $mail->Port = $rsSmtp["smtpport"];
  25. echo "$rsSmtp";
  26.  
  27. if ($mail->Port == 465) {
  28. $mail->SMTPSecure = "ssl";}
  29. $mail->SetFrom($rsSmtp["smtpuser"], "");
  30. $mail->AddReplyTo($rsSmtp["emailreplyto"],"");
  31. $mail->Subject = "";
  32. $arr_to = array($rsEmailSent['emailto']);
  33. foreach($arr_to as $email)
  34. {
  35. $mail->AddAddress($email['addr'], $email['name']);
  36. }
  37. $mail->Body =$rsEmailSent["emailbodyfile"];
  38. $mail->CharSet = "utf-8";
  39. $arr_cc =array($rsEmailSent["emailcc"]);
  40. foreach($arr_cc as $cc){
  41. $mail->AddCC($cc['addr'], $cc['name']);
  42. }
  43. $arr_cc = array($rsEmailSent["emailbcc"]);
  44. foreach($arr_cc as $cc){
  45. echo "xxx";
  46. $mail->AddBCC($cc['addr'], $cc['name']);
  47. }
  48. if($rsEmailSent['emailattachfile1'] && file_exists($rsEmailSent['emailattachfile1']))
  49. $mail->AddAttachment($rsEmailSent['emailattachfile1']);
  50. if($rsEmailSent['emailattachfile2'] && file_exists($rsEmailSent['emailattachfile2']))
  51. $mail->AddAttachment($rsEmailSent['emailattachfile2']);
  52. if($rsEmailSent['emailattachfile3'] && file_exists($rsEmailSent['emailattachfile3']))
  53. $mail->AddAttachment($rsEmailSent['emailattachfile3']);
  54. if($mail->Send())
  55. {
  56. $status = "ok";
  57. // first update the SMTP email count
  58. $sqlUpdate =mysql_query( "update tblSMTP set emailcount=emailcount+1 where smtpid = " .$smtp_id,$conn) ;
  59. }
  60. else
  61. {
  62. $status = $mail->ErrorInfo;
  63. }
  64. $sqlUpdate =mysql_query( " update tblEmailSent set emailstatus = '".$status."' where emailsentid = ".$rsEamilSent['emailsentid'],$conn);
  65. return $status;
  66. }// we found the SMTP information
  67. } // SMTP ID > 0 -- This will process for each record found in the tblEmail Sent
  68. }// while -- Loop through until all records are processed
  69. }
Add Comment
Please, Sign In to add comment