Skip to content

Conversation

@vbudhram
Copy link
Contributor

@vbudhram vbudhram commented Jan 6, 2026

Because

  • Email sending failures with "501 Invalid RCPT TO address provided" errors don't include which recipient addresses are being rejected
  • Debugging SMTP errors requires more context about rejected vs accepted recipients
  • CC recipients aren't logged in error cases, making it harder to identify problematic addresses

This pull request

  • Adds SMTP response code and message to error logs in EmailSender and auth-server mailer
  • Logs rejected and accepted recipient addresses when email sending fails
  • Includes CC recipients in error log details
  • Adds test coverage for SMTP error logging with recipient details
  • Enhances retry attempt logs with SMTP response information

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-12710

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Other information

@vbudhram vbudhram requested a review from a team as a code owner January 6, 2026 18:07
@vbudhram vbudhram self-assigned this Jan 6, 2026
});
};

if (err.response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if there's any reason to not just include this with a null coalescence?

        this.log.warn('mailer.send.retry', {
          err: err.message,
          to: email.to,
          template: email.template,
          retryAttempt: attempt,
          nextAttempt: attempt + 1,
          backoffMs: Math.round(backoffDelay),
          // additional, optional values
          smtpResponse: err.response ?? 'not set',
          smtpResponseCode: err.responseCode ?? 'not set',
        });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No big reason, I do kind of prefer the latter since it doesnt include in the log 😅

Copy link
Contributor

@nshirley nshirley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one minor, non-blocking question

@vbudhram vbudhram merged commit 607a919 into main Jan 12, 2026
22 checks passed
@vbudhram vbudhram deleted the fxa-12710 branch January 12, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants