Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. function automatedEmailer5($host,$message,$subject,$toEmail,$fromName,$fromEmail,$fromPassword, $ccArr)
  2. {
  3.  
  4. $mail = new PHPMailer();
  5. //$mail->SMTPDebug = 2;
  6.  
  7. $mail->IsSMTP();
  8. try{
  9. $mail->Host = $host;
  10. $mail->SMTPAuth = true;
  11. $mail->Username = $fromEmail;
  12. $mail->Password = $fromPassword;
  13.  
  14. $mail->AddReplyTo($fromEmail, $fromName);
  15. $mail->SetFrom($fromEmail, $fromName);
  16. $mail->Subject = $subject;
  17. $mail->AltBody = $message;
  18. $mail->MsgHTML($message);
  19. $mail->Body = $message;
  20. $mail->AddAddress($toEmail,$toEmail);
  21.  
  22. if(!empty($ccArr))
  23. {
  24. if(is_array($ccArr))
  25. {
  26. foreach($ccArr as $ccmail)
  27. {
  28. $mail->AddCC($ccmail,'');
  29. }
  30. }
  31. }
  32. if($mail->Send())
  33. {
  34. return true;
  35. }
  36. //echo "Message Sent OK\n";
  37. } catch (phpmailerException $e) {
  38. //echo $e->errorMessage(); //Pretty error messages from PHPMailer
  39. } catch (Exception $e) {
  40. // echo $e->getMessage(); //Boring error messages from anything else!
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement