gpt4 book ai didi

php - Swift_Mailer + symfony UTF-8

转载 作者:可可西里 更新时间:2023-11-01 12:55:59 28 4
gpt4 key购买 nike

我对 Symfony 中的 Swift_Mailer 有疑问。我正在发送包含大量“à é è”字符的法语电子邮件。起初,当我尝试发送这些字符时,在我的电子邮件客户端中显示正常,但在我同事的电子邮件客户端中却没有。

所以我通过 utf8_encode 函数将邮件的文本放入并再次尝试。现在反之亦然。它在我的电子邮件客户端中显示正常,但在我同事的中却搞砸了。

在 Symfony 中使用 Swift_Mailer 解决这些电子邮件 UTF-8 问题的最佳方法是什么?

最佳答案

使用 $message->toString(); 查看您的电子邮件格式是否正确,这意味着一切都是 UTF-8 或使用正确的欧洲 ISO 字符集 iso-8859- 15。您可以使用 setCharset 告诉它您实际使用的是什么。

The character set of the message (and it’s MIME parts) is set with the setCharset() method. You can also change the global default of UTF-8 by working with the Swift_Preferences class.

Swift Mailer will default to the UTF-8 character set unless otherwise overridden. UTF-8 will work in most instances since it includes all of the standard US keyboard characters in addition to most international characters.

It is absolutely vital however that you know what character set your message (or it’s MIME parts) are written in otherwise your message may be received completely garbled.

http://swiftmailer.org/docs/messages.html#setting-the-character-set

关于php - Swift_Mailer + symfony UTF-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8944169/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com