PHPMailer编码8位 [英] PHPMailer Encoding 8 bit

查看:143
本文介绍了PHPMailer编码8位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发送的电子邮件的Content-Transfer-Encoding有一个奇怪的问题。

I have a weird problem with the Content-Transfer-Encoding of the emails I sent.

添加以下行:

$mail->Encoding = '8bit';

在我的代码中,但发送的引用的可打印的电子邮件...

In my code, but the emails sent with quoted-printable...

来源:

Content-Transfer-Encoding: quoted-printable

我不知道如何使用8位的Content-Transfer-Encoding发送我的电子邮件...

I don't know how to do for sending my emails with a Content-Transfer-Encoding in 8bit...

$ mail-> Encoding ='8bit'; 似乎不工作...

所有代码:

$mail             = new PHPMailer;

$mail->SMTPDebug  = 3;

$mail->isSMTP();
$mail->setLanguage('fr', './PHPMailer/language/');

$mail->CharSet    = 'UTF-8';
$mail->Encoding   = '8bit';
$mail->Host       = 'my_domain.com';
$mail->SMTPAuth   = true;
$mail->Username   = 'news@my_domain.com';
$mail->Password   = 'my_password';
$mail->SMTPSecure = '';
$mail->Port       = 25;
$mail->From       = 'news@my_domain.com';
$mail->FromName   = 'bla';
$mail->addAddress('my@mail.net');
$mail->addReplyTo('news@my_domain.com', 'bla');
$mail->AddCustomHeader("Content-Transfer-Encoding: 8bit\r\n");
$mail->WordWrap   = 10000;
$mail->isHTML(true);
$mail->Subject    = 'Subject';
$mail->Body       = 'bla';
$mail->AltBody    = "bla";

$mail->send();

非常感谢您的帮助

推荐答案

是的,我写了这段代码。 RFC5322第2.1.1节在电子邮件中强加了一个硬线限制(这是规范中的必须条件)。如果您指定了不改变内容(例如 8bit )的行长度变化的编码,则PHPMailer会自动切换到 quoted-可打印编码。这种方法意味着您的确切内容通过编码进行保留,同时允许长行包装。

Yep, I wrote that code. RFC5322 section 2.1.1 imposes a hard line length limit in email messages (it's a MUST requirement in the spec). If you've specified an encoding that does not allow variation in line length without altering the content (such as 8bit), PHPMailer automatically switches to quoted-printable encoding. This approach means that your exact content is preserved through the encoding, while allowing long lines to be wrapped.

如果您想避免这种情况,请(或以其他方式减少)您的行长度小于998个字符。

If you want to avoid this, wrap (or otherwise reduce) your line lengths so they are less than 998 chars.

只是因为你经常能够摆脱这一点,你不应该,只有在<一个href =https://en.wikipedia.org/wiki/Robustness_principle =nofollow> Postel的法律。

Just because you will often be able to get away with this, you shouldn't, if only on the basis of Postel's law.

这篇关于PHPMailer编码8位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆