0

我有这个用 PHP 发送邮件的代码:

$headers = "Content-type: text/html;\r\n";
$headers .= 'From: "Registration" <registration@site.com>' . "\r\n";
$headers .= "Reply-To: registration@site.com\r\n";
$headers .= "Return-Path: registration@site.com\r\n";

$mailresult = mail($to, $subject, $message, $headers, '-f registration@site.com');

邮件发送,发件人地址设置正确,并且工作几乎完美。

问题是邮件在邮件正文中包含From:Reply-To:Return-Path:字段。这是我的 Gmail 界面中的快照:

email_example

以下是原始标题的样子:

X-PHP-Originating-Script: 33:mailtest.php
Content-type: text/html;
Message-Id: <20130316153738.AA739118073@server.com>
Date: Sat, 16 Mar 2013 15:37:38 +0000 (UTC)
From: registration@site.com

From: Registration <registration@site.com>

Reply-To: registration@site.com

Return-Path: registration@site.com

<html>

第一个From:似乎在实际标题中。第二个From:,以及之后的一切都<html>在体内。

如何将这些标题字段从电子邮件正文中取出并放入它们所属的标题中?

4

2 回答 2

1

http://php.net/manual/en/function.mail.php

additional_headers (optional)
[...]
Note:
If messages are not received, try using a LF (\n) only. Some Unix 
mail transfer agents  (most notably qmail) replace LF by CRLF 
automatically (which leads to doubling CR if CRLF is used). This 
should be a last resort, as it does not comply with RFC 2822. 
于 2013-03-16T19:29:17.893 回答
0

删除第一个标题 (text/html) 中的分号。

于 2013-03-16T15:46:13.603 回答