Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function send_email($user_info, $to_emails, $subject, $message_in = "", $format = "email", $attachment = "", $filename="", $attachment_file="", $attachment2 = "", $filename2="", $attachment_file2="") {
- global $setting, $url, $domain;
- $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";
- $domain_short = str_replace("www.", "", $domain);
- $mail = new PHPMailer(); // defaults to using php "mail()"
- $mail->AddReplyTo("donotreply@".$domain_short, $domain_short);
- $mail->SetFrom("donotreply@".$domain_short, $domain_short);
- $mail->AddReplyTo("donotreply@".$domain_short, $domain_short);
- $mail->Subject = $subject;
- if($format == 'SMS'){
- $mail->Body = $message_in;
- }else {
- $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
- $mail->MsgHTML($message_in);
- //ADD ATTACHMENTS
- if($attachment != "" && !is_array($attachment)){
- $attachment = array($attachment);
- }
- if($filename != "" && !is_array($filename)){
- $filename = array($filename);
- }
- if($attachment_file != "" && !is_array($attachment_file)){
- $attachment_file = array($attachment_file);
- }
- $max_loop = count($attachment);
- $max_loop2 = count($attachment_name);
- if($max_loop2 > $max_loop) $max_loop = $max_loop2;
- for($i = 0; $i < $max_loop; $i++){
- if($attachment[$i] != ""){
- $send_file = "../private/scratch/temp_send_".md5(time());
- $file = fopen($send_file, "w");
- fwrite($file, $attachment[$i]);
- fclose($file);
- $mail->AddAttachment($send_file,$filename[$i]);
- } elseif ($attachment_file != "") {
- $mail->AddAttachment($attachment_file[$i],$filename[$i]);
- }
- }
- }
- if(!is_array($to_emails))
- $to_emails = array($to_emails);
- for($e=0;$e<count($to_emails);$e++) {
- $to_email = str_replace(" ", "", $to_emails[$e]);
- if($to_email != ""){
- //$mail->AddAddress($to_email);
- $mail->AddAddress($to_email);
- $mail->Send();
- $mail->ClearAddresses();
- }
- }
- if($format != 'SMS'){
- if($attachment != "")
- unlink($send_file);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement