Comparing version 1.0.14 to 1.0.15
@@ -17,4 +17,4 @@ 'use strict'; | ||
* @param {Object} opts Message options | ||
* @param {Boolean} [opts.trustReceived] If true then parses ip and helo values from Received header | ||
* @param {String} [opts.sender] Address from MAIL FROM. Parsed from Return-Path if not set | ||
* @param {Boolean} [opts.trustReceived] If true then parses ip and helo values from Received header and sender value from Return-Path | ||
* @param {String} [opts.sender] Address from MAIL FROM | ||
* @param {String} [opts.ip] Client IP address | ||
@@ -47,6 +47,2 @@ * @param {String} [opts.helo] Hostname from EHLO/HELO | ||
if (opts.trustReceived) { | ||
if (dkimResult.envelopeFrom && !opts.sender) { | ||
opts.sender = dkimResult.envelopeFrom; | ||
} | ||
let rcvd = receivedChain?.[0]; | ||
@@ -70,3 +66,12 @@ if (rcvd?.from) { | ||
} | ||
if (rcvd['envelope-from']?.value && !opts.sender) { | ||
// prefer Received:envelope-from to Return-Path | ||
opts.sender = rcvd['envelope-from'].value.replace(/[<>]/g, '').trim(); | ||
} | ||
} | ||
if (dkimResult.envelopeFrom && !opts.sender) { | ||
opts.sender = dkimResult.envelopeFrom; | ||
} | ||
} | ||
@@ -73,0 +78,0 @@ |
@@ -135,4 +135,9 @@ 'use strict'; | ||
if (val.key) { | ||
result[val.key] = { value: val.value, comment: val.comment }; | ||
} else if (!result.tls && /tls/i.test(val.comment)) { | ||
let key = val.key.toLowerCase(); | ||
if (key !== 'from' && !result.tls && /tls|cipher=/i.test(val.comment)) { | ||
result.tls = { value: '', comment: val.comment }; | ||
val.comment = ''; | ||
} | ||
result[key] = { value: val.value, comment: val.comment }; | ||
} else if (!result.tls && /tls|cipher=/i.test(val.comment)) { | ||
result.tls = { value: val.value, comment: val.comment }; | ||
@@ -139,0 +144,0 @@ } |
{ | ||
"name": "mailauth", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "Email authentication library for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/mailauth.js", |
226465
3632