Skip to content

Commit

Permalink
fix: conditionally use SRS if SPF passed and DKIM was not passing
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Aug 8, 2020
1 parent 90e9bd4 commit 0f167f1
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,21 @@ class ForwardEmail {
// }`
// );

//
// We will only use SRS if SPF passed and DKIM was not passing
//
// NOTE: Gmail specifically recommends NOT to use SRS if you're forwarding emails
//
// TODO: we may not want to do this if ARC was passing, however not all providers implement ARC yet
//
const from =
authResults &&
authResults.spf &&
authResults.spf.result === 'pass' &&
(!authResults.dkim || authResults.dkim !== 'pass')
? this.srs.forward(mailFrom.address, this.config.srsDomain)
: mailFrom.address;

//
// check if DKIM was valid
//
Expand Down Expand Up @@ -1499,13 +1514,17 @@ class ForwardEmail {
// raw = await getStream(this.dkim.sign(raw));
//
if (isSANB(env.DKIM_PRIVATE_KEY_PATH)) {
raw = await arcSign(
raw,
this.config.dkim.keySelector,
this.config.dkim.domainName,
env.DKIM_PRIVATE_KEY_PATH,
name
);
try {
raw = await arcSign(
raw,
this.config.dkim.keySelector,
this.config.dkim.domainName,
env.DKIM_PRIVATE_KEY_PATH,
name
);
} catch (err) {
this.config.logger.fatal(err);
}
} else {
this.config.logger.fatal(
new Error(
Expand All @@ -1518,20 +1537,6 @@ class ForwardEmail {

try {
const accepted = [];

// preserve original envelope mail from since
// Gmail generaly advises not to use SRS when forwarding to their servers
const from = mailFrom.address;

//
// NOTE: Gmail specifically recommends NOT to use SRS if you're forwarding emails
//
// set SRS
// const from = this.srs.forward(
// mailFrom.address,
// this.config.srsDomain
// );

const selfTestEmails = [];

//
Expand Down

0 comments on commit 0f167f1

Please sign in to comment.