Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. require_once ($_SERVER["DOCUMENT_ROOT"] . '/config.php');
  2. require_once ($_SERVER["DOCUMENT_ROOT"] . '/lib/phpmailer/PHPMailerAutoload.php');
  3. require_once ($_SERVER['DOCUMENT_ROOT'] . '/assets/messaging/email-template.php'); // This is where the templates stored
  4.  
  5. class Email {
  6. public function sendEmail ($send_to_email, $sent_to_name, $template_name) {
  7. // this variables stored in config.php
  8. global $mandrill_host;
  9. global $mandrill_port;
  10. global $mandrill_username;
  11. global $mandrill_password;
  12. global $mandrill_from;
  13. global $mandrill_from_name;
  14.  
  15. $mail = new PHPMailer;
  16. $mail->IsSMTP();
  17. $mail->Host = $mandrill_host;
  18. $mail->Port = $mandrill_port;
  19. $mail->SMTPAuth = true;
  20. $mail->Username = $mandrill_username;
  21. $mail->Password = $mandrill_password;
  22. $mail->SMTPSecure = 'tls';
  23.  
  24. $mail->From = $mandrill_from;
  25. $mail->FromName = $mandrill_from_name;
  26. $mail->AddAddress($send_to_email, $sent_to_name);
  27.  
  28. $mail->IsHTML(true);
  29.  
  30. // I will have CASE here to select $subject, $body and $body_txt
  31. // from /assets/messaging/email-template.php
  32. // based on $template_name parameter
  33.  
  34. $mail->Subject = $subject;
  35. $mail->Body = $body;
  36. $mail->AltBody = $body_txt;
  37.  
  38. if(!$mail->Send()) {
  39. echo 'Message could not be sent.';
  40. echo 'Mailer Error: ' . $mail->ErrorInfo;
  41. exit;
  42. }
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement