Skip to content

fix: fail over mail server addresses - #319

Open
YunQue0912 wants to merge 2 commits into
maathimself:mainfrom
YunQue0912:fix/mail-server-address-fallback
Open

fix: fail over mail server addresses#319
YunQue0912 wants to merge 2 commits into
maathimself:mainfrom
YunQue0912:fix/mail-server-address-fallback

Conversation

@YunQue0912

Copy link
Copy Markdown

Summary

Fixes #318.

Mail server hostnames can resolve to several valid addresses, but MailFlow previously pinned every connection to the first one. An unreachable first address therefore blocked IMAP and SMTP even when another validated address was healthy. SMTP's default connection timeout could also outlive the frontend proxy timeout.

Changes

  • Preserve every validated A/AAAA address while keeping DNS rebinding protection: connection code receives only the addresses validated up front.
  • Let Node try the remaining validated IMAP addresses while retaining the original hostname for TLS SNI and certificate verification.
  • Add one SMTP transport wrapper for user mail, system mail, invite/password-reset mail, and SMTP verification.
  • Limit each SMTP connection and greeting stage to 10 seconds and the failover sequence to a 45-second budget.
  • Retry SMTP only for Nodemailer CONN failures, before authentication or envelope/data commands, so failover cannot duplicate delivered messages.

Testing

  • Backend lint: npm run lint
  • Backend syntax: node --check src/index.js
  • Backend tests: 710 passed across 35 files
  • Backend production audit: 0 vulnerabilities
  • Frontend lint: npm run lint
  • Frontend build: npm run build
  • Frontend tests: 1401 passed across 48 suites
  • Frontend production audit at audit-level=high: passed (two existing moderate React Router advisories have no available fix)
  • Added a local socket test proving same-family IPv4 fallback reaches the second candidate without another DNS lookup
  • git diff --check

Contributor License Agreement

By submitting this pull request I confirm that:

  • I have read and agree to the Contributor License Agreement.
  • My contribution is my own original work (or I have identified any
    third-party material and confirmed it is compatible with the CLA).
  • I have the right to submit this contribution under the terms of the CLA.

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.

Mail server connections do not fail over resolved addresses

2 participants