Merge pull request #359 from mre/fix/list-unsubscribe-header
This commit is contained in:
@@ -133,21 +133,23 @@ export async function sendRawEmail({
|
|||||||
rootContentType = `multipart/related; boundary="${relatedBoundary}"`;
|
rootContentType = `multipart/related; boundary="${relatedBoundary}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build the additional headers (custom headers + List-Unsubscribe), filtering
|
||||||
|
// out empties so we never emit a blank line inside the header section.
|
||||||
|
// Per RFC 5322 §2.1, a blank line terminates the header section, so any blank
|
||||||
|
// line here would push subsequent headers (notably List-Unsubscribe) into the body.
|
||||||
|
const extraHeaderLines = [
|
||||||
|
...(headers ? Object.entries(headers).map(([key, value]) => `${key}: ${value}`) : []),
|
||||||
|
...(unsubscribeHeader ? [unsubscribeHeader] : []),
|
||||||
|
];
|
||||||
|
const extraHeaders = extraHeaderLines.length > 0 ? `\n${extraHeaderLines.join('\n')}` : '';
|
||||||
|
|
||||||
// Build raw MIME message
|
// Build raw MIME message
|
||||||
let rawMessage = `From: ${from.name} <${from.email}>
|
let rawMessage = `From: ${from.name} <${from.email}>
|
||||||
To: ${toHeader}
|
To: ${toHeader}
|
||||||
Reply-To: ${reply || from.email}
|
Reply-To: ${reply || from.email}
|
||||||
Subject: ${content.subject}
|
Subject: ${content.subject}
|
||||||
MIME-Version: 1.0
|
MIME-Version: 1.0
|
||||||
Content-Type: ${rootContentType}
|
Content-Type: ${rootContentType}${extraHeaders}
|
||||||
${
|
|
||||||
headers
|
|
||||||
? Object.entries(headers)
|
|
||||||
.map(([key, value]) => `${key}: ${value}`)
|
|
||||||
.join('\n')
|
|
||||||
: ''
|
|
||||||
}
|
|
||||||
${unsubscribeHeader}
|
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user