Guest User

Untitled

a guest
Oct 3rd, 2018
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. define('MAIL_HOST', 'mail.example.com');
  3. define('MAIL_PORT', 25);
  4. define('MAIL_USERNAME', 'mail@example.com');
  5. define('MAIL_PASSWORD', 'PasswordExample');
  6. define('MAIL_FROM_NAME', 'Example From Name');
  7.  
  8. function phpmailer_mail_send($to, $mail_subject, $mail_body, $who = null, $cc = array(), $bcc = array()){
  9. $phpmailer = new PHPMailer();
  10. $phpmailer->SMTPAuth = true;
  11. $phpmailer->Username = MAIL_USERNAME;
  12. $phpmailer->Password = MAIL_PASSWORD;
  13. $phpmailer->isSMTP();
  14. $phpmailer->Host = MAIL_HOST;
  15. $phpmailer->CharSet = 'UTF-8';
  16.  
  17. //begin: turn off SSL
  18. $phpmailer->SMTPSecure = false;
  19. $phpmailer->SMTPAutoTLS = false;
  20. //end: turn off SSL
  21.  
  22. $phpmailer->Port = MAIL_PORT;
  23. $phpmailer->Sender = MAIL_USERNAME;
  24. if( isset($who) && filter_var($who, FILTER_VALIDATE_EMAIL) !== FALSE ){
  25. $phpmailer->AddReplyTo( $who );
  26. }
  27. $phpmailer->setFrom( MAIL_USERNAME, MAIL_FROM_NAME );
  28.  
  29. $phpmailer->Subject = $mail_subject;
  30. $phpmailer->Body = $mail_body;
  31. $phpmailer->IsHTML(true);
  32. foreach($to as $email_to):
  33. $phpmailer->addAddress($email_to);
  34. endforeach;
  35.  
  36. foreach($cc as $email_cc):
  37. $phpmailer->addCC($email_cc);
  38. endforeach;
  39.  
  40. foreach($bcc as $email_bcc):
  41. $phpmailer->addBCC($email_bcc);
  42. endforeach;
  43. return $phpmailer->send();
  44. }//mail_send
  45. ?>
Add Comment
Please, Sign In to add comment