PHPMailer:如何将 Content-Type 设置为 multipart/alternative [英] PHPMailer : how to set Content-Type to multipart/alternative
问题描述
我使用 phpmailer 发送电子邮件,但邮件的标题中带有 Content-Type: text/html.如何将其更改为 multipart/alternative?
I'm sending e-mails with phpmailer but the messages comes with Content-Type: text/html in the header. how can I change it to multipart/alternative?
它应该类似于 $mail->
it should be something like $mail->
我的配置是:
$mail = new PHPMailer();
$mail->setFrom('mail@mail.com', 'name');
$mail->isHTML(true);
$mail->CharSet = "ISO-8859-1";
$mail->XMailer = ' ';
推荐答案
PHPMailer 会自动为您处理这个问题.PHPMailer 不允许构建任意的 MIME 结构,但它有一大堆涵盖常见场景的预设.例如,要构建一个双格式的 HTML &纯文本消息,只需执行以下操作:
PHPMailer deals with this for you automatically. PHPMailer doesn't allow building arbitrary MIME structures, but it has a whole bunch of presets covering common scenarios. For example, to build a dual-format HTML & plain text message, just do this:
$mail->isHTML();
$mail->Body = "<strong>HTML content</strong>";
$mail->AltBody = "plain text content";
这将生成具有多部分/替代 MIME 结构的消息.
That will produce a message with a multipart/alternative MIME structure.
这篇关于PHPMailer:如何将 Content-Type 设置为 multipart/alternative的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!