Issue Description
The recipient’s DNS records contains four MX records. Two with priority 10 and two with priority 20. The servers with priority 20 are offline.
The MX servers are using self-signed certificate, so Stalwart first fails and then eventually succeeds, but in the mean time, it has several attempts to first connect to MX with priority 20 which is not available.
The problem is, because Stalwarts will connect to the MX with priority 20 before trying to connect to MX with priority 10.
Expected Behavior
Use priority 10 MX before trying higher (in number) priorities which are actually lower priority.
Actual Behavior
Stalwart first connects to MX with priority 20 instead of 10 (mail3.redacted.tld). Then on retry, it connects to another MX with priority 20 (mail4.redacted.tld).
Reproduction Steps
Send an email to a domain with MX records of different priorities.
Relevant Log Output
2026-05-11T08:49:48Z INFO Error fetching TLSA record (dane.tlsa-record-fetch-error) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail3.redacted.tld", causedBy = DNS error (mail-auth.dns-error) { details = "DNSSEC Negative Record Response for _25._tcp.mail3.redacted.tld. IN TLSA, Bogus" }, strict = false, elapsed = 106ms
2026-05-11T08:52:03Z INFO Connection error (delivery.connect-error) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail3.redacted.tld", localIp = 0.0.0.0, remoteIp = 163.159.68.233, remotePort = 25, causedBy = SMTP error occurred (smtp.error) { details = "I/O Error", reason = "Connection timed out (os error 110)" }, elapsed = 134879ms
2026-05-11T08:52:03Z INFO Error fetching TLSA record (dane.tlsa-record-fetch-error) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail4.redacted.tld", causedBy = DNS error (mail-auth.dns-error) { details = "DNSSEC Negative Record Response for _25._tcp.mail4.redacted.tld. IN TLSA, Bogus" }, strict = false, elapsed = 28ms
2026-05-11T08:54:18Z INFO Connection error (delivery.connect-error) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail4.redacted.tld", localIp = 0.0.0.0, remoteIp = 163.159.68.236, remotePort = 25, causedBy = SMTP error occurred (smtp.error) { details = "I/O Error", reason = "Connection timed out (os error 110)" }, elapsed = 135112ms
2026-05-11T08:56:18Z INFO Error fetching TLSA record (dane.tlsa-record-fetch-error) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail2.redacted.tld", causedBy = DNS error (mail-auth.dns-error) { details = "DNSSEC Negative Record Response for _25._tcp.mail2.redacted.tld. IN TLSA, Bogus" }, strict = false, elapsed = 29ms
2026-05-11T08:56:18Z INFO Connecting to remote server (delivery.connect) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail2.redacted.tld", localIp = 0.0.0.0, remoteIp = 84.39.211.236, remotePort = 25, elapsed = 26ms
2026-05-11T08:56:19Z INFO SMTP STARTTLS command (delivery.start-tls) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, domain = "redacted.tld", hostname = "mail2.redacted.tld", version = "TLSv1_3", details = "TLS13_AES_256_GCM_SHA384", elapsed = 83ms
2026-05-11T08:56:23Z INFO Message delivered (delivery.delivered) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, hostname = "mail2.redacted.tld", to = "[email protected]", code = 250, details = "Ok: queued as 4gDYVY3WMBz1C7k", elapsed = 2253ms
2026-05-11T08:56:23Z INFO DSN success notification (delivery.dsn-success) queueId = 306623311685615616, queueName = "remote", from = "[email protected]", to = ["[email protected]"], size = 1296, total = 1, to = "[email protected]", hostname = "mail2.redacted.tld", code = 250, details = "Ok"
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on