以纯文本形式发送的 HTML 电子邮件?(菲律宾比索)


HTML Emails Sending in Plain Text? (PHP)

好的,我知道有一百万个这样的线程,但我尽力浏览它们,找不到真正为我解决问题的线程。 非常感谢任何帮助,因为根据浏览器的不同,它要么隐藏整个内容,要么以纯文本显示。

这是我正在使用的:

$headers = 'From: coupons@madisoncoupons.com'r'n';
$headers .= 'Reply-To: coupons@madisoncoupons.com'r'n';
$headers .= 'MIME-Version: 1.0'r'n';
$headers .= 'Content-type: text/html; charset=ISO-8859-1';
mail($email,$subject,$content,$headers);

$content以 html 和 body 标签开头和结尾,在正文的开头有一个样式标签,其中包含一些 CSS。

您需要

使用正确的引号。 "'r'n"''r'n'是两个完全不同的东西。

阅读 PHP 如何处理字符串,如果你生锈了。

如上所述

@tadman,您必须将标头修改为以下内容

$headers = 'From: coupons@madisoncoupons.com' ."'r'n";
$headers .= 'Reply-To: coupons@madisoncoupons.com' . "'r'n";
  Use this   


   // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "'r'n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "'r'n";
    // More headers
    $headers .= 'From: <info@example.com>' . "'r'n";
    mail($email,$subject,$content,$headers);