当前位置:Gxlcms > PHP教程 > php使用Pear的NetMail发送smtp邮件

php使用Pear的NetMail发送smtp邮件

时间:2021-07-01 10:21:17 帮助过:4人阅读

  1. $params = array('host' => 'localhost',

  2. 'port' => '25',
  3. 'username' => 'test@jbxue.com',
  4. 'password' => 'test');

  5. //$to = $test_mail;

  6. $recipients = $to; 接收人,可以是一个数组来存放多个地址

  7. $headers['From'] = $email;

  8. $headers['To'] = $to;
  9. $headers['Subject'] = $subject;

  10. $body = $message;

  11. //选择smtp的发送方式,当然还支持mail()和sendmail
  12. $mail_object = &Mail::factory('smtp', $params);
  13. if (PEAR::isError($e = $mail_object->send($recipients, $headers, $body))) {
  14. die($e->getMessage() . "\n");
  15. }
  16. ?>

人气教程排行