PHP多部分文本/HTML显示空白

PHP多部分文本/HTML显示空白,php,Php,希望我能得到一些帮助,因为这快把我逼疯了 我尝试过各种各样的脚本来实现这一点,但我遇到的就是这个。这幅画怎么了?我收到一封电子邮件,但它完全是空白的。然而,电子邮件的来源有内容 电子邮件代码 //define receiver and subject $to = 'email@gmail.com'; $subject = 'Test email'; //create boundary $random_hash = md5(date('r', time()));

希望我能得到一些帮助,因为这快把我逼疯了

我尝试过各种各样的脚本来实现这一点,但我遇到的就是这个。这幅画怎么了?我收到一封电子邮件,但它完全是空白的。然而,电子邮件的来源有内容

电子邮件代码

//define receiver and subject

    $to = 'email@gmail.com';
    $subject = 'Test email'; 

//create boundary

    $random_hash = md5(date('r', time())); 

//define the headers

    $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
    $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"$random_hash\""; 

//define the body of the message.

    $message = "--$random_hash\n" .  
    "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .  
    "Content-Transfer-Encoding: 7bit\n\r" .  

    "Hello\n\rWorld!!!\n\r" .  

    "--$random_hash\n" .  
    "Content-Type: text/html; charset=\"iso-8859-1\"\n" .  
    "Content-Transfer-Encoding: 7bit\n\r" .  

    "<h2>Hello World!</h2>\n\r" .  

    "--$random_hash--";

//send the email

    $mail_sent = mail( $to, $subject, $message, $headers );
//定义接收者和主题
$to$email@gmail.com';
$subject='testemail';
//创建边界
$random_hash=md5(日期('r',时间());
//定义标题
$headers=“From:webmaster@example.com\r\n适用于:webmaster@example.com";
$headers.=“\r\n内容类型:多部分/可选;边界=\“$random\u hash\”;
//定义消息的主体。
$message=“--$random\u hash\n”。
“内容类型:文本/普通;字符集=\”iso-8859-1\“\n”。
“内容传输编码:7bit\n\r”。
“你好\n\r世界!!!\n\r”。
“--$random\u hash\n”。
“内容类型:text/html;字符集=\”iso-8859-1\“\n”。
“内容传输编码:7bit\n\r”。
“你好,世界!\n\r”。
“--$random_hash--”;
//发送电子邮件
$mail_sent=mail($to、$subject、$message、$headers);
电子邮件来源(已收到)

接收:(qmail 26359由uid48调用);2013年3月21日10:09:01-0700
日期:2013年3月21日10:09:01-0700
消息ID:
致:me@mydomain.com
主题:测试电子邮件
X-PHP-origing-Script:10001:plug-send-direct.PHP
发件人:webmaster@example.com
答复:webmaster@example.com
内容类型:多部分/备选;边界=“f41fbfe6fda45eb7f5a2724ba135d292”
--f41fbfe6fda45eb7f5a2724ba135d292
内容类型:文本/纯文本;charset=“iso-8859-1”
内容传输编码:7bit
你好
世界!!!
--f41fbfe6fda45eb7f5a2724ba135d292
内容类型:text/html;charset=“iso-8859-1”
内容传输编码:7bit
你好,世界!
--f41fbfe6fda45eb7f5a2724ba135d292--

给出了什么?

尝试确保您的HTML使用“HTML”、“head”和“body”标记正确格式。此外,请确保它们已正确关闭

<html>
<head>
</head>
  <body>
  Stuff
  </body>
</html>

东西

建议研究使用类似于处理复杂电子邮件的框架。利用它应该更容易、更易读,以便正确地完成这项工作。一旦安装好,这里有一个

<html>
<head>
</head>
  <body>
  Stuff
  </body>
</html>