PEAR MAIL发送html邮件

piaoling  2011-06-30 15:25:54

PEAR MAIL发送html邮件

 

include('Mail.php');
include(
'Mail/mime.php');

$text 'Text version of email';
$html '<html><body>HTML version of email</body></html>';
$file '/home/richard/example.php';
$crlf "n";
$hdrs = array(
              
'From'    => 'you@yourdomain.com',
              
'Subject' => 'Test mime message'
              
);

$mime = new Mail_mime($crlf);

$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file'text/plain');

//do not ever try to call these lines in reverse order
$build_params = array("html_charset" =>'UTF-8');//指定html编码为
UTF-8
$body = $mime->get($build_params);
$hdrs $mime->headers($hdrs);

//设定Return-Path
$mail =& Mail::factory('mail',array('Return-Path'=>  sprintf("-f %s", 'support@xxx.com')));
$mail->send('postmaster@localhost'$hdrs$body);

类别 :  PHP(78)  |  浏览(3602)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: