Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $from = "Info <donotreply@test.com>";
  2. $subject = "Calibration will be expiring!";
  3.  
  4. $body = 'Hello';
  5.  
  6. $to = "david@test.com, dono@test.com";
  7. $cc = "rena@test.com";
  8. $bcc = ""; //sometimes BCC can be empty
  9.  
  10. $host = 'smtp.test.com';
  11. $port = '587';
  12. $username = 'donotreply@test.com';
  13. $password = 'dontreply?';
  14.  
  15. $headers = array(
  16. 'Port' => $port,
  17. 'From' => $from,
  18. 'To' => $to,
  19. 'Subject' => $subject,
  20. 'Content-Type' => 'text/html; charset=UTF-8',
  21. 'Cc' => $cc
  22. );
  23.  
  24. $recipients = $to.", ".$bcc.", ".$cc;
  25.  
  26. $smtp = Mail::factory('smtp',
  27. array ('host' => $host,
  28. 'auth' => true,
  29. 'username' => $username,
  30. 'password' => $password));
  31.  
  32. $mail = $smtp->send($recipients, $headers, $body);
  33.  
  34. if (PEAR::isError($mail)) {
  35. echo("<p>" . $mail->getMessage() . "</p>");
  36. } else {
  37. echo("<p>Message successfully sent!</p>");
  38. }
  39.  
  40. Failed to add recipient: @localhost [SMTP: Invalid response code received from server (code: 501, response: 5.1.3 Invalid address [HKXPR02MB0695.apcprd02.prod.outlook.com])]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement