From 1119d8ed7381f02dfe9c60bd8903f2d078554cda Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 24 Jun 2026 17:01:51 +0200 Subject: [PATCH] fix: strip display names from EmailSubmission envelope addresses --- lib/jmap/client.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jmap/client.ts b/lib/jmap/client.ts index eb15ff82..962062f6 100644 --- a/lib/jmap/client.ts +++ b/lib/jmap/client.ts @@ -459,8 +459,11 @@ function sanitizeIdentityDisplayName(name: string | undefined | null): string { } function normalizeEnvelopeRecipients(recipients?: Array): Array<{ email: string }> { + // The JMAP envelope rcptTo/mailFrom take a bare addr-spec, not an RFC 5322 + // mailbox. `to`/`cc`/`bcc` may arrive as "Name "; strip the display + // name or the submission validator rejects the whole envelope (#…). return (recipients || []) - .map((recipient) => typeof recipient === 'string' ? recipient : recipient.email) + .map((recipient) => typeof recipient === 'string' ? parseRecipientString(recipient).email : recipient.email) .map((email) => email.trim()) .filter(Boolean) .map((email) => ({ email })); @@ -2388,13 +2391,10 @@ export class JMAPClient implements IJMAPClient { const buildSubmissionCreate = (submissionId: string): Record => { const create: Record = { emailId: `#${emailId}`, identityId: finalIdentityId }; if (holdForSeconds || envelopeMailFrom) { - const envelopeRecipients = [...to, ...(cc || []), ...(bcc || [])] - .map((email) => email.trim()) - .filter(Boolean) - .map((email) => ({ email })); + const envelopeRecipients = normalizeEnvelopeRecipients([...to, ...(cc || []), ...(bcc || [])]); create.envelope = { mailFrom: { - email: envelopeMailFrom || fromEmail || this.username, + email: parseRecipientString(envelopeMailFrom || fromEmail || this.username).email, ...(holdForSeconds ? { parameters: { HOLDFOR: String(holdForSeconds) } } : {}), }, rcptTo: envelopeRecipients,