Skip to content

fix: decode RFC 2047 encoded-word in SMTP subject headers#322

Merged
butschster merged 1 commit intomasterfrom
fix/decode-rfc2047-smtp-subject
Mar 31, 2026
Merged

fix: decode RFC 2047 encoded-word in SMTP subject headers#322
butschster merged 1 commit intomasterfrom
fix/decode-rfc2047-smtp-subject

Conversation

@butschster
Copy link
Copy Markdown
Member

What

Decode MIME encoded-words (RFC 2047) in SMTP email subject headers before storing them. Subjects like =?utf-8?Q?Norris=E2=80=94Your?= are now correctly decoded to their readable form.

Why

Non-ASCII characters in email subjects arrive as RFC 2047 encoded-words. Without decoding, they appear garbled in the UI (e.g. =?utf-8?Q?...?= instead of readable text).

How

  • Added mime.WordDecoder.DecodeHeader() call in parseEmail() before assigning the subject field
  • The mime package was already imported — no new dependencies

Testing

  • Added TestParseEmail_RFC2047Subject with 4 cases: Q-encoded, B-encoded, mixed encoded/plain, and plain subject
  • All existing SMTP tests continue to pass: go test ./modules/smtp/

SMTP subject headers containing non-ASCII characters arrive as MIME
encoded-words (e.g. =?utf-8?Q?...?=). These were stored as-is,
appearing garbled in the UI. Use mime.WordDecoder to decode them.
@butschster butschster added bug Something isn't working module [Smtp] labels Mar 31, 2026
@butschster butschster linked an issue Mar 31, 2026 that may be closed by this pull request
@butschster butschster merged commit 29c648d into master Mar 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working module [Smtp]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2.0 issues

1 participant