parseServerMessageId (smtp-connection/server-message-id.ts)

nodemailer · src/smtp-connection/server-message-id.ts · typescript · MIT
email

Parses server-assigned Message-ID from SMTP 250 responses, supporting Outlook and SES.

// Source: https://github.com/nodemailer/nodemailer | License: MIT | Copyright 2011-2023 Andris Reinman
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Reads the Message-ID a receiving server gave the message out of its final 250 reply. Some
 * servers replace the Message-ID header of a submitted message with one of their own, and
 * the copy the recipients and the sent folder get carries that one instead of the id the
 * message was built with. Only replies in a format known to carry such an id are read.
 */

// Microsoft 365 and Outlook.com: "250 2.0.0 OK <id@host.prod.outlook.com> [Hostname=...]"
const OUTLOOK_REPLY = /^250 2\.0\.0 OK (<[^<>\s]+\.prod\.outlook\.com>)/i;

// Amazon SES: "250 Ok 0100018b5c3c0a4f-...-000000", the local part of the Message-ID it sets

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key