diff --git a/lib/__tests__/jmap-send-threading.test.ts b/lib/__tests__/jmap-send-threading.test.ts index 342990b2..10f5dc36 100644 --- a/lib/__tests__/jmap-send-threading.test.ts +++ b/lib/__tests__/jmap-send-threading.test.ts @@ -226,6 +226,7 @@ describe('JMAPClient.sendEmail threading headers', () => { email: 'user@example.com', parameters: { HOLDFOR: expect.stringMatching(/^\d+$/) }, }, + rcptTo: [{ email: 'recipient@example.com' }], }, }, }); diff --git a/lib/jmap/client.ts b/lib/jmap/client.ts index 38501f3e..c10c7e2e 100644 --- a/lib/jmap/client.ts +++ b/lib/jmap/client.ts @@ -2242,14 +2242,16 @@ 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 })); create.envelope = { mailFrom: { email: envelopeMailFrom || fromEmail || this.username, ...(holdForSeconds ? { parameters: { HOLDFOR: String(holdForSeconds) } } : {}), }, - ...(envelopeMailFrom - ? { rcptTo: [...to, ...(cc || []), ...(bcc || [])].map((email) => ({ email })) } - : {}), + rcptTo: envelopeRecipients, }; } return { [submissionId]: create };