PEAR MAIL发送html邮件
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);