1

私は非常に単純な PHP 関数を使用して、HTML / プレーンテキストの電子メールを作成しています。gmailや私が見た他の多くのクライアントでうまくいきました。

結局のところ、@live.com アカウントはメールの内容をまったく見ることができません。

関連するコードは次のとおりです。

$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: server@example.com\r\nReply-To: server@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
//add boundary string and mime type specification
$headers .= "Content-Type: multipart/alternative; boundary=$random_hash\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
//define the body of the message.
$message = "This is a MIME encoded message.\r\n\r\n" .
    "--$random_hash\r\n" .
    "Content-Type: text/plain; charset=utf-8\r\n" .
    //"Content-Transfer-Encoding: 7bit\r\n" .
"\r\nthis is plain text.\r\n\r\n" .
"--$random_hash\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
    //"Content-Transfer-Encoding: 7bit\r\n" .
    "\r\n<html><body>this is wonderful <b>HTML</b> text.</body></html>" .
    "\r\n\r\n--$random_hash--\r\n";
mail('someAddress@live.com', 'This is u umlaut: ü', $message, $headers);

HTMLまたはプレーンテキストのみを送信すると、正しく表示されます。

何か案は?

余分なライブラリを使用したくありません。HTML が必要なのは、基本的にはリンクだけです。PHP Multi-Part Text/HTML の空白表示に関する回答は役に立ちません。

ところで、u ウムラウトは、live.com 受信ボックスの電子メール リストに正しく表示されませんが、live.com で電子メールを開くと正しく表示されます...

4

1 に答える 1

0

数時間後に取得しました。

問題はCRLFです。

すべての CRLF ( \r\n) を LF ( \n) に置き換えたところ、うまくいきました。

途中、7bitも8bitに入れ替えました。

件名については、グーグルで簡単に検索できました。これがutf-8の解決策です。

$subject = '=?utf-8?B?' . base64_encode($subject) . '?=';

みんなありがとう!

于 2013-03-22T11:57:43.440 に答える