【问题标题】:How to create email content type to multipart/mixed in php如何在 php 中创建多部分/混合的电子邮件内容类型
【发布时间】:2019-07-22 20:23:48
【问题描述】:

我有一个网站联系表,它以电子邮件的形式发送到我的 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);

【问题讨论】:

    标签: php email


    【解决方案1】:

    您将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);
    

    【讨论】:

    • 已经如此说明了。我还是有问题。我在表格中也有附件。会不会是这个问题?
    猜你喜欢
    • 2016-01-03
    • 2019-05-06
    • 1970-01-01
    • 2014-11-28
    • 2014-09-07
    • 2014-03-31
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    相关资源
    最近更新 更多