I have an issue with Swift_Mailer in Symfony. I am sending e-mail messages in French which contain a lot of "à é è" characters. At first when i tried sending these characters came out fine in my email-client, but in my colleague's email-client they didn't.
So I put the text for the mail through a utf8_encode function and tried again. Now it is vica-versa. It shows fine in my email-client, but screwed up in my colleague's.
What is the best way to solve these e-mail UTF-8 issues with Swift_Mailer in Symfony?
Use $message->toString();
to see if your e-mail is well formatted, meaning everything is UTF-8 or uses the proper European ISO charset iso-8859-15
. You can use setCharset
to tell it what you're actually using.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With