开发者

Some users see HTML in email body after server changes

开发者 https://www.devze.com 2023-03-11 19:04 出处:网络
Pair.net recently upgraded our PHP install and afterwards client started see HTML in email body where previously he had seen formatted email body.

Pair.net recently upgraded our PHP install and afterwards client started see HTML in email body where previously he had seen formatted email body.

I add myself as a CC and my Outlook shows me the formatted body but on the same email he sees code.

Anyone run into this before?

Any hints?

Code looks like:

$headers = "From: $name <$email>\r\n" . 
    "Reply-To: $email\r\n" .
    "X-Mailer开发者_如何学运维: PHP/" . phpversion(). 
    'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$msg = "<html><body><head><style type='text/css'>TD { font-family: Tahoma, Helvetica, sans-serif, Arial, Verdana; font-weight:bold; }</style></head>";
$msg .="<table width='98%' border='0' cellspacing='8'> etc etc etc

mail("$to, me@myoffice.com", $sub, $msg, $headers);

Actual email headers follow:

Delivered-To: xxx@xxx.com
Received: by 10.204.63.10 with SMTP id z10cs87437bkh;
        Wed, 8 Jun 2011 12:50:43 -0700 (PDT)
Received: by 10.216.230.105 with SMTP id i83mr5392587weq.43.1307562643519;
        Wed, 08 Jun 2011 12:50:43 -0700 (PDT)
Return-Path: <anonymous@tinco.pair.com>
Received: from tinco.pair.com (tinco.pair.com [209.68.1.91])
        by mx.google.com with SMTP id f69si2172888wes.55.2011.06.08.12.50.42;
        Wed, 08 Jun 2011 12:50:43 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of anonymous@tinco.pair.com designates 209.68.1.91 as permitted sender) client-ip=209.68.1.91;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of anonymous@tinco.pair.com designates 209.68.1.91 as permitted sender) smtp.mail=anonymous@tinco.pair.com
Received: (qmail 11613 invoked by uid 65534); 8 Jun 2011 19:50:41 -0000
Date: 8 Jun 2011 19:50:41 -0000
Message-ID: <20110608195041.11612.qmail@tinco.pair.com>
To: sales@yyy.com, xxx@xxx.com
Subject: WEBSITE BERG SELECTION FORM
From: David XXX <xxx@xxx.com>
Reply-To: xxx@xxx.com
X-Mailer: PHP/5.3.6MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1


Update (original below):

You forgot a newline in your headers ;) Between the X-Mailer header and the MIME-Version header there should be an \r\n... it's swallowing the MIME-Version (in your eg headers too):

$headers = "From: $name <$email>\r\n" . 
    "Reply-To: $email\r\n" .
    "X-Mailer: PHP/" . phpversion()."\r\n".
    "MIME-Version: 1.0\r\n" .
    "Content-Type: text/html;charset=\"iso-8859-1\"\r\n";

Old (potential) answer

I think this may be a case of... case, the correct header is:

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

There may also be a transfer-encoding issue (the Content-Transfer-Encoding header)


I continue to think server upgrades and switch to qmail may have done this but issue is resolved by switching to SwiftMail.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号