有没有办法更改 SwiftMailer 中标头的编码?

Khr*_*riz 5 php swiftmailer symfony

我用来SwiftMailer发送电子邮件,但我在UTF-8主题方面遇到一些编码问题。Swiftmailer 默认使用QPHeaderEncoder对电子邮件标头进行编码,并且 safeMap 看起来对某些UTF-8法语字符存在一些问题。我使用的一个主题包含单词 trouv\xc3\xa9 (在法语中找到),当该主题到达用户时,它会显示 trouv。

\n\n

我想使用类似于NativeQPContentEncoder可用作内容编码器的东西,但对于标题只有Base64Quoted Printable编码器。

\n\n

有没有办法解决这个问题,也许我做错了什么,所以我将我正在使用的代码粘贴到这里

\n\n
$message = Swift_Message::newInstance()\n\n// set encoding in 8 bit\n->setEncoder(Swift_Encoding::get8BitEncoding())\n\n// Give the message a subject\n->setSubject($subject)\n\n// Set the From address with an associative array\n->setFrom(array($from => $niceFrom))\n\n// Set the To addresses with an associative array\n->setTo(array($to)) ;\n
Run Code Online (Sandbox Code Playgroud)\n

cro*_*nfy 2

检查您的 PHP 配置mbstring.func_overload选项中是否有除 之外的任何值0。如果是,请将其更改为0,重新加载您的网络服务器并尝试再次发送消息。

mbstring.func_overload 覆盖一些字符串 PHP 函数,并可能导致 UTF-8 出现棘手的错误。

就我个人而言,我通过禁用 解决了这个问题mbstring.func_overload