如何使用PHP的Mail类发送html格式的Email
Web Tips 2005/11/08 17:47 弄了一下午,总算明白email是啥子回事了。简单说控制email的内容如何显示主要是看头文件的一个参数Content-Type,通过设置它,可以很方面的定义你的email到底是用文本方式还是html方式,或者多种格式混用都可以。在PHP中,我一般喜欢使用pear带的Mail类来发送Email.
发送Html格式Email的方法如下:
$headers['From'] = $system_mail;
$headers['Reply-To'] = $system_mail;
$headers['Cc'] = $system_mail;
$headers['To'] = $recipients;
$headers['Subject'] = $subject;
$headers['MIME-Version']= "1.0";
$headers['Content-Type'] = 'text/html;charset="gb2312"';
$mail_object =& Mail::factory('smtp', $mail_params);
$mail_object->send($recipients, $headers, nl2br($body));
发送多种格式甚至附件的办法,请参看Mail类Mail_Mime中相关的部分。郁闷啊,原来这么简单的问题,居然搞了这么久才搞定,rp问题大了
发送Html格式Email的方法如下:
$headers['From'] = $system_mail;
$headers['Reply-To'] = $system_mail;
$headers['Cc'] = $system_mail;
$headers['To'] = $recipients;
$headers['Subject'] = $subject;
$headers['MIME-Version']= "1.0";
$headers['Content-Type'] = 'text/html;charset="gb2312"';
$mail_object =& Mail::factory('smtp', $mail_params);
$mail_object->send($recipients, $headers, nl2br($body));
发送多种格式甚至附件的办法,请参看Mail类Mail_Mime中相关的部分。郁闷啊,原来这么简单的问题,居然搞了这么久才搞定,rp问题大了

