Skip to content

fix: keep display names intact when parsing recipient lists - #25

Merged
Schero94 merged 1 commit into
mainfrom
fix/display-name-parsing
Nov 18, 2026
Merged

Schero94 merged 1 commit into
mainfrom
fix/display-name-parsing

Conversation

@Schero94

Copy link
Copy Markdown
Owner

What

send() normalised to/cc/bcc by splitting strings at every comma, also inside quoted display names, and lower-casing the pieces. "Ops, Live" <cc@example.com> reached the provider as "ops, Live" <cc@example.com>; a name with angle brackets lost its case. Affects 4.6.1 for SMTP, Gmail, Outlook, Yahoo and Mailgun (SendGrid sends bare addresses in this release, so only the addresses matter there and they were already right).

Fix

Recipients are parsed with nodemailer's RFC 5322 address parser (the one the transports already use, no new dependency). Only the address part is lower-cased; the display name is kept byte for byte and quoted only when it needs quotes. Groups and unparseable values are returned trimmed and are validated later as before.

Tests

  • tests/address-display-names.test.js (37 tests): names with commas, escaped quotes, unicode and angle brackets, mixed lists and arrays, through SendGrid and Mailgun (fake fetch) and at the SMTP, Gmail, Outlook and Yahoo provider boundary. 25 of them fail on main before the fix. One test pins that bare address lists normalise exactly as before.
  • tests/helpers/provider-send-harness.js: fake Strapi with the real router and a recording fetch (test-only).
  • Gate: lint, format check, npm test (581: 578 passed, 0 failed, 3 skipped), npm run test:multi-instance (49: 46 passed, 3 skipped).
  • Live (SendGrid sandbox, this branch's code): a send with "Ops, Live" and "Ops <Team>" cc names was accepted (200), addresses lower-cased.

Found by the live SendGrid suite on #23/#20 (SG-9); the same fix is in #23 and will drop out of it on rebase.

🤖 Generated with Claude Code

send() split to/cc/bcc strings at every comma, also inside quoted
display names, and lower-cased the pieces, so "Ops, Live" <cc@x>
reached the provider as "ops,  Live" <cc@x> (SMTP, Gmail, Outlook,
Yahoo and Mailgun; SendGrid sends bare addresses in this release).
Recipients are now parsed with nodemailer's RFC 5322 address parser,
which the transports already use; only the address part is lower-cased
and the name is kept, quoted only when it needs quotes. Bare address
lists normalise exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Schero94
Schero94 merged commit 0769739 into main Nov 18, 2026
7 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 18, 2026
## [4.6.2](v4.6.1...v4.6.2) (2026-11-18)

### Bug Fixes

* keep display names intact when parsing recipient lists ([#25](#25)) ([0769739](0769739))

### Fixed

* **Recipient names with commas, quotes or angle brackets arrive unchanged.** `"Doe, Jane" <jane@example.com>` in to, cc or bcc used to be split at the comma and partly lower-cased, so the recipient saw the name "doe,  Jane" (SMTP, Gmail, Outlook, Yahoo and Mailgun). Addresses are now read with the same RFC 5322 parser the transports use; only the address is lower-cased, never the name. Bare address lists are normalised exactly as before.
Schero94 added a commit that referenced this pull request Nov 18, 2026
The display-name fix shipped in 4.6.2 (#25); this branch's copy of it
drops out of the diff. The test keeps this branch's stricter SendGrid
check (SendGrid now receives the names).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant