发送电子邮件并在php中构建Mimes


Sending email and constructing Mimes in php

我正在发送一封带有php的电子邮件。这些是我的标题。

$headers = array (
'MIME-Version' => '1.0',
'From' => $from,
'To' => $to,
'Return-Path' => 'info@example.com',
'Content-Type'=>  'multipart/alternative',
'boundary'=>$boundary,  
'Subject' => $subject);
 $random_hash = md5(date('r', time())); 

那是我的html/textbody:

    $bodyHTML = "
 --PHP-alt-$random_hash 
Content-Type: text/plain; charset=utf-8 
Content-Transfer-Encoding: 7bit
http://example.com/app_dl.php?app_id=$_GET[app_id] to download your $app_name app 'n'r'n'r
Want to get tons more hot apps for free! anywhere anytime? Download our app on http://example.com' 'n'r'n'r
example.com team
--PHP-alt-$random_hash 
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<p><a href='http://example.com/app_dl.php?app_id=$_GET[app_id]'>Click Here</a> to download your $app_name app</p>
<p>Want to get tons more hot apps for free! anywhere anytime? Download our app on <a href='http://example.com'>example.com</a></p>
<br/>
<p>example.com team</p> 
--PHP-alt-$random_hash--";

我已经在这个问题上停留了很长时间,现在..我错过了什么

尝试删除前导空格并添加换行符:

    $boundary = "PHP_alt_$random_hash";
    $bodyHTML = "--$boundary
Content-Type: text/plain; charset=utf-8 
Content-Transfer-Encoding: 7bit
http://example.com/app_dl.php?app_id=$_GET[app_id] to download your $app_name app 'n'r'n'r
Want to get tons more hot apps for free! anywhere anytime? Download our app on http://example.com' 'n'r'n'r
example.com team
--$boundary 
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<p><a href='http://example.com/app_dl.php?app_id=$_GET[app_id]'>Click Here</a> to download your $app_name app</p>
<p>Want to get tons more hot apps for free! anywhere anytime? Download our app on <a href='http://example.com'>example.com</a></p>
<br/>
<p>example.com team</p>
--$boundary--";