Advertisement
Guest User

Untitled

a guest
Sep 7th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1.  
  2. function sendEmailWithAttach($subject, $body, $to, $add_cc, $file) {
  3. require_once LIB_DIR.'/phpmailer/class.phpmailer.php';
  4.  
  5. try {
  6. $mail = new PHPMailer(true);
  7. $mail->IsSMTP();
  8. $mail->Host = MAIL_HOST;
  9. $mail->SMTPAuth = true;
  10. $mail->SMTPDebug = 2;
  11. $mail->Debugoutput = 'html';
  12. //$mail->SMTPSecure = "tls";
  13. $mail->Port = MAIL_PORT;
  14. $mail->Username = MAIL_USERNAME;
  15. $mail->Password = MAIL_PASSWORD;
  16.  
  17. if ($add_cc) {
  18. foreach ($add_cc as $c)
  19. $mail->AddCC($c);
  20. }
  21. $mail->AddReplyTo(MAIL_REPLY_TO, MAIL_REPLY_TO_NAME);
  22.  
  23. $mail->From = MAIL_FROM;
  24. $mail->FromName = MAIL_FROM_NAME;
  25.  
  26. $mail->AddAddress($to);
  27. //$mail->AddCC(MAIL_ADMIN);
  28. $mail->Subject = $subject;
  29. $mail->CharSet = "utf-8";
  30. $mail->WordWrap = 80;
  31. $mail->IsHTML(true);
  32. $mail->MsgHTML($body, HTML_DIR);
  33.  
  34. if (file_exists($file))
  35. $mail->AddAttachment($file);
  36.  
  37. $return = $mail->Send();
  38.  
  39. if (!$return) echo "\n *** ".$mail->ErrorInfo . " \n ";
  40.  
  41. } catch (phpmailerException $e) {
  42. echo $e->errorMessage();
  43. } catch (Exception $e) {
  44. echo $e->getMessage();
  45. }
  46.  
  47. return $return;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement