用Pear Mail发邮件

WBOY
发布: 2016-07-25 09:08:32
原创
1379 人浏览过
  1. error_reporting(E_ALL);
  2. require 'Mail.php';
  3. require 'Mail/mime.php';
  4. $text = "Text version of email\nMessage made with PHP";
  5. $html = 'HTML version of email
    ';
  6. $html .= 'Message made with 用Pear Mail发邮件 ';
  7. $crlf = "\n";
  8. $from = 'from_address@163.com';
  9. $to = 'to_address@qq.com';
  10. $password = '123456';
  11. $mail_config=array(
  12. "host"=>"smtp.163.com",
  13. "port"=>25,
  14. "auth"=>true,
  15. "username"=>$from,
  16. "password"=>$password,
  17. "from"=>$from,
  18. );
  19. $hdrs = array(
  20. 'From'=>$from,
  21. 'Subject'=>'Test HTMl Email with Embedded Image'
  22. );
  23. $mime = new Mail_mime($crlf);
  24. $mime->setTXTBody($text);
  25. $mime->addHTMLImage('php.gif','image/gif','12345',true);
  26. $mime->setHTMLBody($html);
  27. $body = $mime->get();
  28. $hdrs = $mime->headers($hdrs);
  29. $mail = Mail::factory('smtp',$mail_config);
  30. $succ = $mail->send($to,$hdrs,$body);
  31. if (PEAR::isError($succ))
  32. {
  33. echo 'Email sending failed: ' . $succ->getMessage();
  34. }
  35. else
  36. {
  37. echo 'Email sent succesfully';
  38. }
  39. ?>
复制代码


相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!