PHP脚本通过电子邮件发送HTML仅输出明文

时间:2012-09-02 23:56:31

标签: php html email

这是在bluehost上 - 我尝试过向gmail以外的其他客户端发送,我仍然遇到同样的问题:我的所有html都显示为纯文本/标签。没有渲染成html。

    $to = '###@gmail.com';

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: $from \r\n";


    $headers = array(

    'From' => "###@####.com",

    'Cc' => "####@gmail.com",

    'Subject' => "Your Reminder From Remindmeto.org",

    );



    $body = '<html><body>';
    $body .= '<h1>From the mists of memory I speak...</h1>';
    $body .= "$image";
    $body .= '</body></html>';



    $mail = Mail::factory("mail");

    $mail->send($to, $headers, $body);

1 个答案:

答案 0 :(得分:0)

您正在设置标题两次。改为:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from \r\n";
$headers .= "Cc: ####@gmail.com \r\n";
$headers .= "Subject: Your Reminder From Remindmeto.org \r\n";

摆脱阵列部分:)