New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
TroubleshootingUpdated 26 Oct 2026

MIME Encoded-Words in Email Headers: Fixing Garbled Subjects, Names and Non-ASCII Text

How RFC 2047 encoded-words let headers carry non-ASCII text, the =?UTF-8?B?...?= syntax, Q and B encodings, folding rules, common garbling causes, SMTPUTF8 and how to test subjects and names in several languages.

VR
Written by Valentina Reyes
E-commerce Email Specialist
Reviewed by Omar Haddad
  • Published8 Mar 2025
  • Read time6 min
  • Length1,179 words
Share this guide

Email headers were designed for plain ASCII. Yet subjects such as "Réservation confirmée", names like "Zoë Müller" and entire lines in Hindi, Japanese or Arabic travel through the internet every second. The mechanism that makes this possible is the MIME encoded-word, defined in RFC 2047. When it works nobody notices. When it fails, recipients see question marks, boxes, strange sequences such as "=?UTF-8?B?" or text with accents replaced by the wrong letters. This guide explains what an encoded-word is, how to read one, which headers may contain them, what goes wrong in practice and how to test your sending code. It complements UTF-8 in email, emoji in email and email localization.

Form=?charset?encoding?encoded-text?= with B (Base64) or Q (quoted-printable style) encoding
WhereText parts of headers such as Subject, display names and comments; never in addresses
LimitEach encoded-word is at most 75 characters, so long text is split and folded
FixLet a mail library encode headers, use UTF-8, and test with real multilingual samples

What an encoded-word looks like

Subject: =?UTF-8?B?UsOpc2VydmF0aW9uIGNvbmZpcm3DqWU=?=
From: =?UTF-8?Q?Zo=C3=AB_M=C3=BCller?= <[email protected]>
Subject: =?UTF-8?B?4KSF4KSq4KSo4KS+IOCkheCkleCkvuCkieCkguCknyDgpKjgpL/gpLDgpY3gpK4=?=

Reading from left to right: the opening =?, the character set (UTF-8 is the sensible default), a question mark, the encoding letter, another question mark, the encoded text and the closing ?=. Mail clients decode these automatically for display. The two encodings are:

EncodingLetterHow it worksBest for
Base64BThe bytes of the text are Base64-encodedMostly non-Latin scripts (Chinese, Japanese, Arabic, Hindi) where most characters need encoding
Quoted-printable styleQPrintable ASCII stays as is; other bytes become =XX; spaces become underscoresMostly Latin text with a few accents, so the result stays somewhat readable

The 75-character limit means a long subject is split into several encoded-words separated by folding whitespace. Each word must contain whole characters; splitting a multi-byte UTF-8 character across two encoded-words is a classic bug that produces garbled text in some clients. Correct libraries split at character boundaries.

Where encoded-words may appear

PlaceAllowed?Notes
SubjectYesThe most common case
Display name in From, To, Cc, Reply-ToYesOnly in the name part, not the address. Names with special characters must also be quoted correctly
Comments in structured headersYesRare in practice
Email address (local part or domain)NoInternationalised addresses use SMTPUTF8 or IDNA, covered below
Header field namesNoNames stay ASCII
Message-ID, Date, ReceivedNoStructured; ASCII only. See Date header
Attachment filenamesSeparate mechanismUse RFC 2231 parameter encoding or the library's support. See MIME attachments

Why subjects and names get garbled

SymptomLikely causeFix
Question marks or boxes instead of lettersThe text was converted to a character set that cannot hold it, or the sender used 8-bit text in the header without declaring a charsetUse UTF-8 end to end and let the library encode the header
Accented letters replaced by two odd characters (for example é for é)UTF-8 bytes were interpreted as a legacy single-byte charset, or the other way aroundDeclare the correct charset; avoid double conversion
Raw =?UTF-8?B?...?= visible to the readerThe encoded-word was not recognised: missing spaces, wrong delimiters, extra quotes or an encoded-word inside a quoted stringDo not wrap encoded-words in quotes; separate adjacent words with whitespace
Subject cut off or characters missing in the middleA multi-byte character was split across two encoded-wordsSplit on character boundaries; use a maintained library
Name shows with backslashes or stray quotesSpecial characters such as commas or quotes were not escaped before encodingQuote or encode the display name according to the library rules
Different text in different clientsA client with limited charset support or a gateway that rewrites headersTest the same message in several clients; check gateways
Emoji turn into question marksThe database or code path used a 3-byte UTF-8 variant (for example MySQL utf8 instead of utf8mb4)Store and handle text as full UTF-8. See emoji
Subject fine in one language, broken in anotherHard-coded charset such as ISO-8859-1Switch to UTF-8 everywhere

Rules for senders

  1. Use a mail library that encodes headers automatically and consistently. Hand-built encoded-words are a common source of bugs.
  2. Choose UTF-8 as the charset for headers, text parts and HTML parts, and declare it in the Content-Type header of each part.
  3. Do not mix raw 8-bit text into headers. If your platform accepts a Unicode subject, make sure it encodes before sending, and that no earlier step converts the string.
  4. Keep subjects reasonably short. Long non-Latin subjects expand when encoded and may be truncated by clients.
  5. Avoid hidden or control characters, including zero-width characters, which can look like obfuscation to filters and cause display issues.
  6. Encode display names, not addresses. If an address itself is internationalised, use IDNA for the domain and check that the receiving side supports SMTPUTF8.
  7. Sign after encoding. DKIM signs the header as it will be transmitted; reencoding after signing breaks signatures. See reading authentication results.

SMTPUTF8 and internationalised addresses

RFC 6531 defines SMTPUTF8, an SMTP extension that lets headers carry raw UTF-8 and allows non-ASCII mailbox names such as 用户@例子.公司. Both sides must support it. If the next hop does not advertise SMTPUTF8 in its EHLO response, a sender cannot deliver a message that requires it, and either downgrades (where possible) or fails with an error. For ordinary marketing and transactional mail, encoded-words remain the safe, universally understood method. Use SMTPUTF8 only when you must support internationalised addresses, and test with the providers your audience uses. See SMTP extensions.

Testing

  1. Build a small set of test strings: Latin with accents, Cyrillic, Greek, Arabic (right-to-left), Hindi, Chinese, Japanese, Korean, emoji and a long mixed string.
  2. Send each as a subject and as a display name through your real sending path to accounts at several providers and clients.
  3. Open the received source and check the header: the charset should be UTF-8 and each encoded-word under 75 characters.
  4. Check the display in desktop, web and mobile clients, in list view and in notifications.
  5. Test replies and forwards: the quoted subject should keep its characters.
  6. Check logs, analytics and webhooks for the same strings, because reports often use a different path and break encoding there.
  7. Put the test set in your regression suite so later library updates do not reintroduce problems.

Debugging a broken subject

  1. Get the original message source and find the Subject header.
  2. Decode each encoded-word by hand or with a tool (for example Python's email.header.decode_header) and compare the result with the intended text.
  3. If the decoded text is already wrong, the fault is before sending: a database, form, template or API step changed the string.
  4. If the decoded text is right but the client shows garbage, look at the charset declaration and at gateways that rewrite headers.
  5. Fix the earliest wrong step, resend and verify in the same clients.

Encoded-words are old, but they are the reason a French subject, a Japanese name or a Hindi headline survives its trip across the internet. Let a good library do the encoding, keep everything in UTF-8 and test with real languages, and garbled headers become a rare surprise.

Send tested, authenticated mail Check records and headers on your sending domain.

Open the checker

References and further reading

Frequently asked questions

What is a MIME encoded-word?

A way to put non-ASCII text in an email header using the form =?charset?encoding?text?=, defined in RFC 2047.

What is the difference between B and Q encoding?

B uses Base64 and suits non-Latin scripts; Q keeps ASCII readable and suits Latin text with few accents.

Why does my subject show question marks?

The text was converted to a charset that cannot represent it, or was double-converted somewhere before sending.

Can I put encoded-words in the email address?

No. Encoded-words are only for text parts such as display names; internationalised addresses need IDNA or SMTPUTF8.

How do I test multilingual subjects?

Send a set of sample strings in several scripts to different clients and read the source to check UTF-8 and word lengths.

Topics#encoding#mime#headers#utf-8#localization
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales