非常简单的HTML /纯文本电子邮件在microsoft live.com中根本没有显示

I have been using a very simple PHP function to construct HTML / plain-text emails. It worked well in gmail and many other clients I saw.

As it turns out, @live.com accounts don't get to see the email content at all.

Here's the relevant code:

$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with 

$headers = "From: server@example.com
Reply-To: server@example.com
";
$headers .= "MIME-Version: 1.0
";
//add boundary string and mime type specification
$headers .= "Content-Type: multipart/alternative; boundary=$random_hash
";
$headers .= "Content-Transfer-Encoding: 7bit
";
//define the body of the message.
$message = "This is a MIME encoded message.

" .
    "--$random_hash
" .
    "Content-Type: text/plain; charset=utf-8
" .
    //"Content-Transfer-Encoding: 7bit
" .
"
this is plain text.

" .
"--$random_hash
" .
"Content-Type: text/html; charset=utf-8
" .
    //"Content-Transfer-Encoding: 7bit
" .
    "
<html><body>this is wonderful <b>HTML</b> text.</body></html>" .
    "

--$random_hash--
";
mail('someAddress@live.com', 'This is u umlaut: ü', $message, $headers);

If I only send either HTML or plain-text, it will display properly.

Any ideas?

I do not want to use an extra library. All I need the HTML for is links, basically. The answers on PHP Multi-Part Text/HTML showing blank don't help me.

And btw: the u umlaut is displayed incorrectly in the email list in the live.com inbox but displayed correctly when I open the email in live.com...

Got it after a few hours.

The issue are the CR and LF.

I replaced all CRLF () by LF () and it worked.

On the way, I also replaced 7bit by 8bit.

And as for the subject line, that was an easy one to google for, and this is the solution for utf-8:

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

Thanks guys!