Why do I get an error saying “SMTPUTF8 is required, but was not offered by host”?

If you send mail from a script on your site, but the script doesn’t properly encode non-ASCII characters in the message headers, you might get a “bounce message” saying “SMTPUTF8 is required, but was not offered by host”.

This happens if you try to send a message with headers including, say:

From: "🐅 Tîger Téchnølogies 🐅" <from@example.com>
Subject: 🐯🐯🐯

These headers contain non-ASCII, UTF-8 characters, which is a problem because the original Internet specifications for mail servers don’t allow anything except ASCII text in message headers. Only mail servers that support a special feature called SMTPUTF8 will accept headers like this.

Our mail servers support SMTPUTF8, but the whole thing only works if the receiving mail server also supports it. If it doesn’t, you get the bounce.

The way to solve this is to MIME encode the headers in your script. When they’re encoded, the headers above would look like:

From: =?UTF-8?B?IvCfkIUgVMOuZ2VyIFTDqWNobsO4bG9naWVzIPCfkIUiIDxmcm8=?=
 =?UTF-8?B?bUBleGFtcGxlLmNvbT4=?=
Subject: =?UTF-8?Q?=F0=9F=90=AF=F0=9F=90=AF=F0=9F=90=AF?=

This might seem like gibberish, but it contains only ASCII characters, so you can send it even to servers that don’t support SMTPUTF8. All popular mail programs will decode it and show it as the original UTF-8 text.

If the text you’re trying to encode is always going to be the same, you can use an online MIME Header Encoder website to find the encoded version.

If the text will vary for each message you send, you can encode it in your script. For example, in PHP, you can use iconv_mime_encode like this:

$from = iconv_mime_encode('From', '"🐅 Tîger Téchnølogies 🐅" <from@example.com>');
$subject = iconv_mime_encode('Subject', '🐯🐯🐯');
mail('address@example.com', $subject, $from);