Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. function send_email($user_info, $to_emails, $subject, $message_in = "", $format = "email", $attachment = "", $filename="", $attachment_file="", $attachment2 = "", $filename2="", $attachment_file2="") {
  2.  
  3. global $setting, $url, $domain;
  4.  
  5. $message_in .= "<br><br><br>This is an automatic message from ProductionWidgets.com. Please do not reply to this message. If you have received this message in error, please contact abuse@productionwidgets.com";
  6.  
  7. $domain_short = str_replace("www.", "", $domain);
  8.  
  9.  
  10.  
  11.  
  12. $mail = new PHPMailer(); // defaults to using php "mail()"
  13. $mail->AddReplyTo("donotreply@".$domain_short, $domain_short);
  14. $mail->SetFrom("donotreply@".$domain_short, $domain_short);
  15. $mail->AddReplyTo("donotreply@".$domain_short, $domain_short);
  16. $mail->Subject = $subject;
  17.  
  18. if($format == 'SMS'){
  19. $mail->Body = $message_in;
  20. }else {
  21. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  22. $mail->MsgHTML($message_in);
  23.  
  24.  
  25. //ADD ATTACHMENTS
  26. if($attachment != "" && !is_array($attachment)){
  27. $attachment = array($attachment);
  28. }
  29. if($filename != "" && !is_array($filename)){
  30. $filename = array($filename);
  31. }
  32. if($attachment_file != "" && !is_array($attachment_file)){
  33. $attachment_file = array($attachment_file);
  34. }
  35.  
  36.  
  37. $max_loop = count($attachment);
  38. $max_loop2 = count($attachment_name);
  39. if($max_loop2 > $max_loop) $max_loop = $max_loop2;
  40.  
  41. for($i = 0; $i < $max_loop; $i++){
  42. if($attachment[$i] != ""){
  43. $send_file = "../private/scratch/temp_send_".md5(time());
  44. $file = fopen($send_file, "w");
  45. fwrite($file, $attachment[$i]);
  46. fclose($file);
  47. $mail->AddAttachment($send_file,$filename[$i]);
  48. } elseif ($attachment_file != "") {
  49. $mail->AddAttachment($attachment_file[$i],$filename[$i]);
  50. }
  51. }
  52.  
  53.  
  54. }
  55.  
  56. if(!is_array($to_emails))
  57. $to_emails = array($to_emails);
  58.  
  59.  
  60.  
  61. for($e=0;$e<count($to_emails);$e++) {
  62.  
  63.  
  64.  
  65. $to_email = str_replace(" ", "", $to_emails[$e]);
  66.  
  67.  
  68.  
  69. if($to_email != ""){
  70. //$mail->AddAddress($to_email);
  71. $mail->AddAddress($to_email);
  72. $mail->Send();
  73. $mail->ClearAddresses();
  74. }
  75. }
  76.  
  77. if($format != 'SMS'){
  78. if($attachment != "")
  79. unlink($send_file);
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86. return true;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement