PHPMailer UTF8 unicode charset support in email messages

I recently came across a problem where email being generated from our system contained user input that used the UTF8 unicode charset. PHP UTF8 support is normally pretty good however it seems that PHPMailer does not do automatic charset detection on outgoing emails. The solution though is quite simple. Just set the charset to UTF8 manually in PHPMailer and UTF8 encoding will be used. The code required is:

$myPhpMailerObj->CharSet = 'UTF-8';


Anonymous said...

Worked for me. Ta!

Mike Hazell said...

Thanks, probably could have worked that out myself. Sometimes google is easier than thinking.

Anonymous said...

Thank you. I had no idea this could have been a problem.

Jleagle said...


rogerthedodger said...

Thanks Paul.

I used a cheeky little number:

$myPhpMailerObj->CharSet = mb_detect_encoding($body);

This meant that no matter what encoding the text was, the mailer was set for it =)

Post a Comment