我有一个网站联系表单,可以通过电子邮件发送到我的iPhone。问题是我收到以下消息:
“由于格式化,无法显示此消息。请发件人使用其他格式或电子邮件程序再次发送它。multipart / mixed”这与电子邮件内容类型以及如何在我的PHP代码中进行修复有关吗?
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:".$from_email."\r\n";
$headers .= "From:".$from_email."\r\n";
$headers .= "Reply-To: ".$sender_email."" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($message_body));
$sentMail = mail($recipient_email, $subject, $body, $headers);
答案 0 :(得分:0)
您将Content-Type
指定为标题字符串。
假设您要在标头后面加上标准的点符号,则应使用:
$headers .= "Content-Type: multipart/mixed";
随后,它将成为您的mail()
函数的第四个参数:
mail($address, $subject, $message, $headers);
这是一个基本示例:
$address = 'sample@sample.com';
$subject = 'Subject';
$message = 'Message';
$headers = "From: My Name<something@something.com>\n";
$headers .= "Reply-To: something@something.com \n";
$headers .= "Content-Type: multipart/mixed";
mail($address, $subject, $message, $headers);