我可以發送文本很好,只是HTML罰款,但是當我結合兩者如下電子郵件發送但身體是空的。電子郵件正文是空的,MIME多部分(文本和HTML)
$to = "[email protected]";
$subject = "Welcome";
$boundary = md5(date('U'));
$headers = "From: Company <[email protected]>" . "\n".
"X-Mailer: PHP/".phpversion() ."\n".
"MIME-Version: 1.0" . "\n".
"Content-Type: multipart/alternative; boundary=".$boundary. "\n";
"Content-Transfer-Encoding: 7bit". "\n";
// TEXT EMAIL PART
$text = "Congratulations";
// HTML EMAIL PART
$html = "<html><body>\n";
$html .= "<div>Congratulations</div>";
$html .= "</body></html>\n";
$message = "Multipart Message coming up" . "\n\n".
"--".$boundary.
"Content-Type: text/plain; charset=\"iso-8859-1\"" .
"Content-Transfer-Encoding: 7bit".
$text.
"--".$boundary.
"Content-Type: text/html; charset=\"iso-8859-1\"".
"Content-Transfer-Encoding: 7bit".
$html.
"--".$boundary."--";
mail($to, $subject, $message, $headers);
我假設你已經設置了$邊界的東西? – bumperbox 2011-04-14 20:49:20
也看看http://swiftmailer.org/可以爲你做很多努力 – bumperbox 2011-04-14 20:50:05
是的,它現在。錯過了當我剪切和粘貼時添加它。 – John 2011-04-14 20:51:14