纯文本版的电子邮件无效

时间:2013-05-23 14:28:54

标签: php email multipart plaintext

所以我有脚本发送纯文本和html的多部分电子邮件,有些原因明文版本不起作用,但我可以看到它是在我在gmail中显示原始文件时发送的。它只是显示html虽然我点击消息乱码?

// headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: From Name  <'. FROM_EMAIL. ">\r\n";
$headers .= 'To: '.$member->member_info['memem']. "\r\n";
$headers .= 'Bcc: receipts@gmail.com' . "\r\n";
$headers .= "Subject: Registration Receipt\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";


// Additional headers
 $message . "\r\n\r\n--" . $boundary . "\r\n";
 $message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";

 $message .= $receipt_txt;//plain text

 $message .= "\r\n\r\n--" . $boundary . "\r\n";
 $message .= "Content-type: text/html;charset=utf-8\r\n\r\n";

 $message .= $receipt_html;//html

 $message .= "\r\n\r\n--" . $boundary . "--";




mail( $member->member_info['memem'], 'Registration Receipt', $message, $headers );

1 个答案:

答案 0 :(得分:0)

垃圾。我找到了。 “$ message。”\ r \ n \ r \ n--“。$ border。”\ r \ n“;”应该是“$ message。=”\ r \ n \ r \ n - “。$ border。”\ r \ n“;”我觉得愚蠢:(