用Pear Mail发邮件
<无详细内容>
<?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'; } ?>
- 上一篇:一个游戏的解答
- 下一篇:PHP与MongoDB简介|安全|M+PHP应用实例
精彩图集
精彩文章