设置邮件头:
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=gb2312\r\n";
$headers .= "From: [email protected]\r\n";
$headers .= "Cc: [email protected]\r\n";
$headers .= "Bcc: [email protected]\r\n";

解决方案 »

  1.   

    设置邮件头:
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=gb2312\r\n";
    $headers .= "From: [email protected]\r\n";
    $headers .= "Cc: [email protected]\r\n";
    $headers .= "Bcc: [email protected]\r\n";mail($to, $subject, $message, $headers);
      

  2.   

    那我整个HTML文件写在那里啊?
      

  3.   

    哈哈,很简单的。
    如果你学会了发附件的邮件,那么发html格式的邮件就相当容易了。
    模板例子:
    mail_demo.shtmlThis is a multi-part message in MIME format.--<%NextPart_1%>
    Content-Type: multipart/alternative;
    boundary="<%NextPart_0%>"
    --<%NextPart_0%>
    Content-Type: text/plain;
    charset="gb2312"
    Content-Transfer-Encoding: base64
    --<%NextPart_0%>
    Content-Type: text/html;
    charset="gb2312"
    Content-Transfer-Encoding: 8bit<html>
    <body>
    <a herf="http://www.csdn.net"> <img src="<PhotoCid%>"> </a>
    </body>
    </html>--<%NextPart_0%>----<%NextPart_1%>
    Content-Type: application/octet-stream;
    name="<%PhotoName%>"
    Content-Transfer-Encoding: base64
    Content-ID: <<%PhotoCid%>><%PhotoMessage%>--<%NextPart_1%>-- 关键部分:
    1、头部必须有一个声明 Content-Type: multipart/alternative;
    2、NextPart_1,NextPart_0,每个标签之间的关系。
    3、html中图片的<PhotoCid%>必须是附件中的对应的Content-ID:<<%PhotoCid%>>.
    注:Content-ID:<123456>,这里是有"<"和">"的。