chatmail / chatmail/filtermail
Distinct permanent errors for HTTPS /mxdeliv
- Dominant language
- Rust
- Stars
- 11
- Forks
- 4
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 17
Description
Currently all HTTPS `/mxdeliv` errors are treated the same way, as a temporary errors:
https://github.com/chatmail/filtermail/blob/f5605bf5df6186ea3e75a3d93b81f248c6702a7b/src/transport.rs#L212-L214
madmail, which introduced /mxdeliv, does the same, ignoring HTTPS error codes and treating them the same way as timeouts or network errors.
In filtermail-transport there is a workaround that avoids the problem of trying HTTPS /mxdeliv each time when it is not supported, a cooldown of 30 minutes for HTTPS after falling back to SMTP and successfully delivering there:
https://github.com/chatmail/filtermail/blob/f5605bf5df6186ea3e75a3d93b81f248c6702a7b/src/transport.rs#L231-L237
Some error types are [specified](https://github.com/themadorg/madmail/blob/6a46c500e24bee0dd7b09ffbb8295995bb5b0fd2/docs/chatmail/RELAY.md#wire-format-mxdeliv) (EDIT: the latest version as of 2026-06-14 is https://github.com/themadorg/madmail/blob/62d4e0391c0ff68220605d2cbd96c0cdd315462d/docs/TDD/07-federation.md), but the document just describes what madmail returns and not how to treat the errors. Error "404 Not Found" for "no valid recipients" is not usable as permanent error because it is indistinguishable from hitting a web server that is not a mail server, you can do `curl -X POST https://chatmail.at/mxdeliv` and get error 404.
Timeouts and HTTPS error 500 are temporary. 4xx errors should likely be permanent, but because /mxdeliv has no discovery mechanism, error 404 likely should likely be treated as temporary as well, and not used for "no valid recipients", because it is otherwise not possible distinguish between an error and unsupported `/mxdeliv`.
We have three cases to design for:
1. Email servers that don't support /mxdeliv but have port 25 open. Should not hit them with /mxdeliv requests for each new message.
2. Email servers that support /mxdeliv and have port 25 open. Probably want to use HTTP here, it is supposed to be faster at least if we keep the connection, because of less round trips (with HTTP/2 upgrade could even use pipelining, it is not currently supported though, see https://github.com/chatmail/filtermail/pull/122#issuecomment-4336628770 and comments above), but now we block HTTP after any temporary error for 30 minutes.
3. Email servers that support /mxdeliv and have port 25 filtered. This currently times out on port 25 instead of returning an error even if `/mxdeliv` is reachable and returns permanent error.
There are also related comments at https://github.com/chatmail/filtermail/pull/122#discussion_r3155577766
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.