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:ものは実際のヘッダー内にあるようです。2 番目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 に答える