does anyone know if you can send emails using utf-8 instead of ascii in CraftCMS 2?

I am using the Freeform plugin to send entries from a "Contact Us" form to a CRM that needs to receive the e-mails in utf-8 but they are coming in as ASCII. Is there a way to change this in either the plugin or in Craft?

Thank you!

2 Answers 2


Craft 2 uses PHPMailer for its email sending library.

It does have a public CharSet property that Craft explicitly sets to UTF-8 when sending emails.

The problem is, they have logic that overwrites our UTF-8 value in certain circumstances... namely when no 8-bit characters are involved in the body setting it to us-ascii: https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L2453-L2458

Not sure of a good resolution as this seems like undesired behavior in the PHPMailer library to me.

FWIW, the upcoming Craft 3 has ditched PHPMailer in favor of Swift Mailer where it is much more customizable.

  • Thank you, that's what we kind of figured after conducting a few tests, and hoping for a work around that would help our client until our Ducks are in a row for the update to Craft 3. For now we are hiding a an UTF-8 character in the form to trick the mailer into sending the form in the charset we want. Would just deleting that logic break everything?
    – Lily K
    Apr 18, 2018 at 14:57
  • Changing any of the core files would run the risk of them being overwritten in the future on an auto/manual update. Not sure what other runtime implication deleting that code might have.
    – Brad Bell
    Apr 18, 2018 at 21:08
  • 1
    Thank you Brad! In the end we added an random Ü to the end of the outgoing e-mail template that seemed to do the trick. Weird and hackey but I like to think of it as an extra happy smiley face for those hardworking customer service reps who have to read the submissions. Once we upgrade to Craft 3 we will look into more sophisticated options. Your insight is very appreciated!
    – Lily K
    Apr 19, 2018 at 16:05

does anyone know if you can send emails using utf-8 instead of ascii in CraftCMS 2?

$message = craft()->templates->render('path/to/file/', $someVariables);

$email = new EmailModel();

$email->fromEmail = $adminEmail;
$email->replyTo = $adminEmail;
$email->sender = $adminEmail;
$email->fromName = craft()->getSiteName();
$email->toEmail = $mail;    
$email->subject = $subject;
$email->htmlBody = $message;  // <-- this is html and it will be send as utf8

  • Thank you but unfortunetly this won't work, i'm not writing a plug in. When Craft sends an e-mail it seems to either send it as a charset ASCII or UTF-8 based on the characters used. If I add an ø is sends the e-mail as UTF-8, if I don't it switches to ASCII. I'm trying to figure out how to change this to send the e-mail as UTF-8 as a default.
    – Lily K
    Apr 17, 2018 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.