【问题标题】:HTML mail not showing in client Outlook ExpressHTML 邮件未显示在客户端 Outlook Express 中
【发布时间】:2013-02-24 22:49:38
【问题描述】:

我正在使用以下代码发送电子邮件:

        $to = "****.co.uk";
        $subject = "Membership submission";
        $body = "";

        $date = date('d/m/Y H:i:s');

        $body .= "<b>REF</b>: " . $postId . "<br />";  
        $body .= "<b>On</b>: " . $date . "<br />";
        $body .= "<b>First name</b>: " . $postFirstName . "<br />";
        $body .= "<b>Last name</b>: " . $postLastName . "<br />";
        $body .= "<b>Company name</b>: " . $postCompanyName . "<br />";
        $body .= "<b>Address</b>:<br /> " . nl2br( $postAddress ) . "<br />";
        $body .= "<b>Telephone number</b>: " . $postTelephoneNumber . "<br />";          
        $body .= "<b>Email</b>: " . $postEmail . "<br />";       
        $body .= "<b>Website</b>: " . $postWebsite . "<br />";        
        $body .= "<b>Skills</b>:<br /> " . nl2br( $postSkills ) . "<br />";      
        $body .= "<b>Payment method</b>: " . $postPaying . "<br />";    

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        // Additional headers
        $headers .= 'From: noreply@*****.co.uk' . "\r\n";

        if ( mail( $to, $subject, $body, $headers ) ) {
        //

在 outlook.com 和 windows 8 邮件程序中,它可以正常运行。 但是,当发送到我客户的桌面 Outlook 程序时,它会像这样:

Content-type: text/html; charset=iso-8859-1

 From: noreply@***
 X-Brightmail-Tracker: AAAAAQAAAlk=

 <b>REF</b>: 513a8440922ea<br /><b>On</b>: 09/03/2013 00:40:59<br /><b>First
 name</b>: a name<br /><b>Last name</b>: a last name<br /><b>Company name</b>: My
 Company name<br /><b>Address</b>:<br /> an address,<br />

 2,<br />

 3,<br />

 4,<br />

 postcode<br /><b>Telephone number</b>: 521213091<br /><b>Email</b>:
 ****.co.uk<br /><b>Website</b>: site.com<br
 /><b>Skills</b>:<br /> I do not have any skills to assist with.<br />

 <br />

 Sorry<br /><b>Payment method</b>: Bank transfer<br />

我的代码有什么问题吗?

我刚刚尝试添加这个:

Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

现在我在 outlook.com 中收到的电子邮件只有 HTML。所以杀了它?啊,这是什么问题!

【问题讨论】:

标签: php html email header


【解决方案1】:
【解决方案2】:

我不确定,但这可能是因为您缺少开始 &lt;html&gt; 和结束 &lt;/html&gt; 标记。

mail() 函数的 example in the documentation 可能会有所帮助。

【讨论】:

  • 不,它没有......我想我添加了一个标题......但它似乎在那之后工作?但我就是不相信.. 所以不确定答案是什么,但不是 html。
【解决方案3】:

这是我正在使用的代码-sn-p。我工作得很好。

// Boundary 
$innerboundary ="=_".time()."_=";

// Mail-Header 
$header ="MIME-Version: 1.0\n"; 
$header.="From: sender@mail.com\n"; 
$header.="Reply-To: sender@mail.com\n"; 
$header.="X-Mailer: kmPHP-Mailer\n"; 
$header.="Content-Type: multipart/alternative;\n\tboundary=\"".$innerboundary."\"\n";

// Mail-subject 
$subject ="Subject goes here"; 
$body ="";

// HTML part 
$body.="\n--".$innerboundary."\n"; 
$body.="Content-Type: text/html;\n\tcharset=\"iso-8859-1\"\n"; 
$body.="Content-Transfer-Encoding: base64\n\n"; 
$body.=chunk_split(base64_encode(($html_string_goes_here)))."\n\n"; 
$body.="\n--".$innerboundary."--\n"; 
$body.="\n\n"; 

【讨论】:

  • 感谢您的帮助,但这似乎在电子邮件中输出废话
猜你喜欢
  • 2013-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-11
  • 1970-01-01
  • 1970-01-01
  • 2018-04-01
  • 1970-01-01
相关资源
最近更新 更多