From c01635e7b83e5437cc349a3b9340ead6f9cbcd6a Mon Sep 17 00:00:00 2001 From: niftylettuce Date: Sun, 22 Dec 2019 20:59:06 -0600 Subject: [PATCH] fix: require From header for RFC 5322 compliance (matches Gmail spec) --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5dec3708..80f3e7f9 100644 --- a/index.js +++ b/index.js @@ -514,8 +514,12 @@ class ForwardEmail { let rewriteFriendlyFrom = false; // headers object (includes the \r\n\r\n header and body separator) const { headers } = messageSplitter; - const originalFrom = - headers.getFirst('from') || session.envelope.mailFrom.address; + const originalFrom = headers.getFirst('from'); + + if (!originalFrom) + throw new CustomError( + 'Your message is not RFC 5322 compliant, please include a valid "From" header.' + ); // parse the from address and set a parsed reply-to if necessary const fromAddress = addressParser(originalFrom)[0];