Non-ASCII subject / names in To, CC, BCC

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
Ilija Studen
Forum Newbie
Posts: 7
Joined: Thu Sep 07, 2006 10:58 am
Location: Novi Sad, Serbia

Non-ASCII subject / names in To, CC, BCC

Post by Ilija Studen »

Users have reported several occurrences where Subjects and Sender names that contain "special" characters are lost. How can I make sure that these information is set as UTF.

All of the data is pulled from DB and we cannot guarantee that it will always be done through UTF connection, but I can do character conversion before setting the values. Any pointer would be great.

PS: I can provide screenshot with all headers as an example.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Non-ASCII subject / names in To, CC, BCC

Post by Chris Corbyn »

Currently:

Code: Select all

$message->headers->setEncoding('B'); //This is only needed because of a bug in v3
$message->headers->setCharset('utf-8');
$message->setCharset('utf-8'); //You probably want this line too
And just because v4 is about to be released, in v4 if you upgrade:

Code: Select all

$message->getHeaders()->setCharset('utf-8');
 
//Or if you want to affect the entire message
$message->setCharset('utf-8');
Post Reply