Posted By

kendsnyder on 01/18/11


Tagged

email pear smtp


Versions (?)

Send SMTP emails with PEAR


 / Published in: PHP
 

  1. function sendHtmlEmail($recipient, $subject, $html) {
  2. // Need PEAR in include path with installed: Mail, Net_Smtp
  3. $headers = array(
  4. 'From' => 'whateveremail',
  5. 'Reply-To' => 'whateveremail',
  6. 'Cc' => 'whateveremail',
  7. 'MIME-Version' => '1.0',
  8. 'Content-Type' => 'text/html; charset=UTF-8',
  9. 'To' => $recipient,
  10. 'Subject' => $subject,
  11. );
  12. $smtp = Mail::factory('smtp', array (
  13. 'host' => 'smtp.server.whatever',
  14. 'port' => 25,
  15. 'auth' => true,
  16. 'username' => ,
  17. 'password' => )
  18. );
  19.  
  20. $mail = $smtp->send($recipient, $headers, $html);
  21.  
  22. if (PEAR::isError($mail)) {
  23. trigger_error($mail->getMessage(), E_USER_WARNING);
  24. return false;
  25. }
  26. return true;
  27. }

Report this snippet  

You need to login to post a comment.