加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Swift_Mailer symfony UTF-8

发布时间:2020-12-13 18:02:04 所属栏目:PHP教程 来源:网络整理
导读:我在Symfony中遇到 Swift_Mailer问题.我正在发送包含大量“àéè”字符的法语电子邮件.起初,当我尝试发送这些字符时,我的电子邮件客户端很好,但在我的同事的电子邮件客户端,他们没有. 所以我通过utf8_encode函数为邮件添加文本并再次尝试.现在它反过来了.它
我在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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读