发送PHP HTML电子邮件显示代码

时间:2012-10-24 14:00:48

标签: php html email

我有一个发送确认电子邮件的网站。当我直接向我的Gmail帐户或工作帐户发送电子邮件时,它会按预期显示,但是当它通过godaddy注册的另一个电子邮件地址或通过Network Solutions注册时,它会显示如下:

Reply-To: tom@yahoo.com

    Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
    Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com>
    Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)

    <html><body><h1>You have been registered for Future Event</h1><div><b>Date:</b> March 4th, 2013</div><div><b>Time:</b> 12:00am</div><div><p>Come one come all.  Step into the future</p></div><div><a href="http://example.com/create_ical/?m=6ea267734713bd10" target="_blank">Download to your calendar</a></div><a href="http://www.example.com/adtracking/?a=532ff9c94b851df4&l=http://www.example.com/?x=ad" target="_blank"  style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"><img src="http://www.example.com/i/ads/57db2ce3d22e4636_ad_mrc_300_250.jpg"  style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"></a></body></html>

Godaddy基本上说这是我的错,他们不负责任。

这是我设置标题的方式:

$_HEADERS = "From: " . $_HOST["email"] . "\r\nReply-To: " . $_HOST["email"] . "";
$_HEADERS .= "\r\nContent-Type: text/html; boundary=\"PHP-alt-".$_random_hash."\"";

这是完整的电子邮件:

Delivered-To: through-godaddy-to-my-account-at@gmail.com
Received: by 10.58.227.40 with SMTP id rx8csp526380vec;
        Wed, 24 Oct 2012 06:46:02 -0700 (PDT)
Received: by 10.52.90.212 with SMTP id by20mr22114953vdb.118.1351086361703;
        Wed, 24 Oct 2012 06:46:01 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of server1.serverdomain.com designates 66.18.17.26 as permitted sender) client-ip=66.18.17.26;
Message-ID: <5087f119.9bcfdc0a.6321.234eMFETCHER_ADDED@google.com>
Received: by 10.220.207.155 with POP3 id fy27mf482750vcb.7;
        Wed, 24 Oct 2012 06:46:01 -0700 (PDT)
X-Gmail-Fetch-Info: email-at-godaddy@example.com 1 pop.secureserver.net 110 email-at-godaddy@example.com
Received: (qmail 13064 invoked by uid 30297); 24 Oct 2012 13:45:46 -0000
Received: from unknown (HELO m1pismtp01-016.prod.mesa1.secureserver.net) ([10.8.12.16])
          (envelope-sender <apache@server1.serverdomain.com>)
          by p3plsmtp14-04.prod.phx3.secureserver.net (qmail-1.03) with SMTP
          for <email-at-godaddy@example.com>; 24 Oct 2012 13:45:46 -0000
X-IronPort-Anti-Spam-Result: ApIxAH/wh1BCEhEa/2dsb2JhbABEghiJdKNaMQEBkGdwgQiCGoEzID4ZASqFSQeCGAkBAw8LmXGPHId3ASOVAmeDSYIegQYDlCKCaIQihXCFEA
Received: from server1.serverdomain.com ([66.18.17.26])
  by m1pismtp01-016.prod.mesa1.secureserver.net with ESMTP; 24 Oct 2012 06:45:45 -0700
Received: by server1.serverdomain.com (Postfix, from userid 48)
    id 9B59E10076; Wed, 24 Oct 2012 08:45:43 -0500 (CDT)
To: email-at-godaddy@example.com
Subject: You have successfully registered for Future Event
From: tom@yahoo.com
X-Nonspam: None
Date: Wed, 24 Oct 2012 06:46:01 -0700 (PDT)

Reply-To: tom@yahoo.com

Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com.com>
Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)

<html><body><h1>You have been registered for Future Event</h1><div><b>Date:</b> March 4th, 2013</div><div><b>Time:</b> 12:00am</div><div><p>Come one come all.  Step into the future</p></div><div><a href="http://example.com/create_ical/?m=6ea267734713bd10" target="_blank">Download to your calendar</a></div><a href="http://www.example.com/adtracking/?a=532ff9c94b851df4&l=http://www.example.com/?x=ad" target="_blank"  style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"><img src="http://www.example.com/i/ads/57db2ce3d22e4636_ad_mrc_300_250.jpg"  style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"></a></body></html>

1 个答案:

答案 0 :(得分:1)

如果您要发送多部分消息,则只应使用“边界”。可能这会混淆GoDaddy的解析器,或垃圾邮件检查程序,或其他任何东西;他们打开你的邮件并重新打包,看起来“错误”。

然而,如果他们不像谷歌那样“接受他们所接受的那样自由”,那么这不是GoDaddy的错。

查看PHPMailer或multipart structure等类;或仅发送没有边界的HTML(参见例如http://www.w3schools.com/php/func_mail_mail.asp)。

更新

将您的标题与其他HTML邮件进行比较,会出现一些差异:

From: tom@yahoo.com
X-Nonspam: None
Date: Wed, 24 Oct 2012 06:46:01 -0700 (PDT)

Reply-To: tom@yahoo.com

Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com.com>
Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)


From: <redacted>
To: <redacted>
Date: Mon, 04 Apr 2011 10:33:32 +0200
MIME-Version: 1.0
Content-Type: text/html; charset="ISO-8859-15"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

具体来说,“回复:”周围的空行可能会使系统认为标题已终止,以下内容是电子邮件文本内容。这可能是由汇编标题时的行终止符不正确引起的。