php 用Pear Mail发邮件
用Pear Mail发邮件 **[PHP]代码**[代码片段(48行)]
[PHP]代码
<?php error_reporting(E_ALL); require 'Mail.php'; require 'Mail/mime.php'; $text = "Text version of email\nMessage made with PHP"; $html = '<html><body>HTML version of email<br />'; $html .= 'Message made with <img src="12345" /></body></html>'; $crlf = "\n"; $from = 'from_address@163.com'; $to = 'to_address@qq.com'; $password = '123456'; $mail_config=array( "host"=>"smtp.163.com", "port"=>25, "auth"=>true, "username"=>$from, "password"=>$password, "from"=>$from, ); $hdrs = array( 'From'=>$from, 'Subject'=>'Test HTMl Email with Embedded Image' ); $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->addHTMLImage('php.gif','image/gif','12345',true); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail = Mail::factory('smtp',$mail_config); $succ = $mail->send($to,$hdrs,$body); if (PEAR::isError($succ)) { echo 'Email sending failed: ' . $succ->getMessage(); } else { echo 'Email sent succesfully'; } ?>
- 上一篇:Android 和 PHP 之间进行数据加密传输
- 下一篇:php 随机颜色生成器
精彩图集
精彩文章