Skip to content

Commit

Permalink
fix: added courtesy notice for SMTP configuration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Nov 26, 2024
1 parent 8228996 commit f7604cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/phrases.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ module.exports = {
'Newsletter approval required for <span class="notranslate">%s</span>',
NEWSLETTER_APPROVAL_REQUIRED_MESSAGE:
'We detected that you attempted to send an outbound SMTP newsletter for <strong class="notranslate">%s</strong>. Your domain does not yet have newsletter support approved, and an admin has been notified to begin review. This process usually is resolved within 2-4 hours, but sometimes it may longer.',
RETURN_PATH_ERROR_SUBJECT:
'<span class="notranslate">%s</span> needs outbound SMTP configured or re-verified',
RETURN_PATH_ERROR_MESSAGE:
'<p>The domain <strong class="notranslate">%s</strong> had an issue with its outbound SMTP configuration:</p><p class="text-center mb-0"><a href="%s" class="btn btn-lg btn-danger">Resolve Issues</a></p>',
BOUNCE_WEBHOOK_ERROR_SUBJECT:
'<span class="notranslate">%s</span> had a bounce webhook error',
BOUNCE_WEBHOOK_ERROR_MESSAGE:
Expand Down
42 changes: 42 additions & 0 deletions helpers/process-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

const os = require('node:os');
const punycode = require('node:punycode');
const { Buffer } = require('node:buffer');
const { createPublicKey, randomBytes, createHmac } = require('node:crypto');

Expand Down Expand Up @@ -583,6 +584,47 @@ async function processEmail({ email, port = 25, resolver, client }) {

// verify Return-Path (enforces domain reputation)
if (srsDomain !== returnPath) {
//
// NOTE: this indicates typically an outbound SMTP configuration issue
// (as a courtesy send this once a week to the user on a per-domain basis)
//
const cache = await client.get(`return_path_check:${domain.id}`);
if (!cache) {
await client.set(
`return_path_check:${domain.id}`,
true,
'PX',
ms('7d')
);
// send an email to all admins of the domain
const obj = await Domains.getToAndMajorityLocaleByDomain(domain);
const subject = i18n.translate(
'RETURN_PATH_ERROR_SUBJECT',
obj.locale,
domain.name
);
const message = i18n.translate(
'RETURN_PATH_ERROR_MESSAGE',
obj.locale,
domain.name,
`${config.urls.web}/${
obj.locale
}/my-account/domains/${punycode.toASCII(domain.name)}/verify-smtp`
);
// TODO: if error occurs then unset cache
await emailHelper({
template: 'alert',
message: {
to: obj.to,
subject
},
locals: {
message,
locale: obj.locale
}
});
}

const err = Boom.badRequest(i18n.translateError('INVALID_RETURN_PATH'));
err.returnPathResults = returnPathResults;
err.srsDomain = srsDomain;
Expand Down

0 comments on commit f7604cb

Please sign in to comment.