【问题标题】:PHPMailer : how to set Content-Type to multipart/alternativePHPMailer:如何将 Content-Type 设置为 multipart/alternative
【发布时间】:2016-10-26 18:29:40
【问题描述】:

我正在使用 phpmailer 发送电子邮件,但邮件的标题中带有 Content-Type: text/html。如何将其更改为 multipart/alternative?

它应该类似于 $mail->

我的配置是:

$mail = new PHPMailer();

$mail->setFrom('mail@mail.com', 'name');
$mail->isHTML(true);                                
$mail->CharSet = "ISO-8859-1";
$mail->XMailer = ' ';

【问题讨论】:

    标签: php phpmailer


    【解决方案1】:

    PHPMailer 会自动为您处理这个问题。 PHPMailer 不允许构建任意 MIME 结构,但它有一大堆涵盖常见场景的预设。例如,要构建双格式 HTML 和纯文本消息,只需这样做:

    $mail->isHTML();
    $mail->Body = "<strong>HTML content</strong>";
    $mail->AltBody = "plain text content";
    

    这将产生具有多部分/替代 MIME 结构的消息。

    【讨论】:

      猜你喜欢
      • 2013-09-02
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 2012-11-13
      • 2021-08-28
      • 2018-01-26
      • 1970-01-01
      相关资源
      最近更新 更多