fix: strip display names from EmailSubmission envelope addresses
This commit is contained in:
+6
-6
@@ -459,8 +459,11 @@ function sanitizeIdentityDisplayName(name: string | undefined | null): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizeEnvelopeRecipients(recipients?: Array<string | EmailAddress>): Array<{ email: string }> {
|
function normalizeEnvelopeRecipients(recipients?: Array<string | EmailAddress>): 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 <addr>"; strip the display
|
||||||
|
// name or the submission validator rejects the whole envelope (#…).
|
||||||
return (recipients || [])
|
return (recipients || [])
|
||||||
.map((recipient) => typeof recipient === 'string' ? recipient : recipient.email)
|
.map((recipient) => typeof recipient === 'string' ? parseRecipientString(recipient).email : recipient.email)
|
||||||
.map((email) => email.trim())
|
.map((email) => email.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map((email) => ({ email }));
|
.map((email) => ({ email }));
|
||||||
@@ -2388,13 +2391,10 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
const buildSubmissionCreate = (submissionId: string): Record<string, unknown> => {
|
const buildSubmissionCreate = (submissionId: string): Record<string, unknown> => {
|
||||||
const create: Record<string, unknown> = { emailId: `#${emailId}`, identityId: finalIdentityId };
|
const create: Record<string, unknown> = { emailId: `#${emailId}`, identityId: finalIdentityId };
|
||||||
if (holdForSeconds || envelopeMailFrom) {
|
if (holdForSeconds || envelopeMailFrom) {
|
||||||
const envelopeRecipients = [...to, ...(cc || []), ...(bcc || [])]
|
const envelopeRecipients = normalizeEnvelopeRecipients([...to, ...(cc || []), ...(bcc || [])]);
|
||||||
.map((email) => email.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
.map((email) => ({ email }));
|
|
||||||
create.envelope = {
|
create.envelope = {
|
||||||
mailFrom: {
|
mailFrom: {
|
||||||
email: envelopeMailFrom || fromEmail || this.username,
|
email: parseRecipientString(envelopeMailFrom || fromEmail || this.username).email,
|
||||||
...(holdForSeconds ? { parameters: { HOLDFOR: String(holdForSeconds) } } : {}),
|
...(holdForSeconds ? { parameters: { HOLDFOR: String(holdForSeconds) } } : {}),
|
||||||
},
|
},
|
||||||
rcptTo: envelopeRecipients,
|
rcptTo: envelopeRecipients,
|
||||||
|
|||||||
Reference in New Issue
Block a user