我有这个用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界面中的内容快照:
以下是原始标题的样子:
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>
的所有内容都在正文中。
如何将这些标题字段从电子邮件正文中删除到它们所属的标题中?
答案 0 :(得分: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.
答案 1 :(得分:0)
删除第一个标题中的分号(text / html)。