Commit Graph

62 Commits

Author SHA1 Message Date
l ed5dfbe0ff test: place #[tokio::test] after rstest case macros (#192)
Otherwise only the first case is built.
2026-07-01 14:51:37 +02:00
Jagoda Estera Ślązak 7f14693b31 feat(logs): Log incoming mailer-daemon message sources (#191)
Logs mailer-daemon messages separately from other unencrypted mails.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-30 19:00:13 +02:00
Jagoda Estera Ślązak d5ac67ecff feat(transport): Worker eviction (#185)
Adds max worker capacity of 500 to the worker pool,
and an automatic shutdown of idle workers.
Messages that would cause the capacity to be exceeded,
are deferred.

Additionally, ensures that the same worker
is not spawned by two tasks at the same time.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-27 10:54:38 +02:00
Jagoda Ślązak db86cfc6ed refactor: Implement Display for AddressDomain
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-26 11:11:30 +02:00
Jagoda Ślązak c7452526fa test: Test filtermail-transport
Adds filtermail-transport tests and
a test setup for recording SMTP transactions.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-26 11:11:20 +02:00
Jagoda Ślązak 7ea7904ea0 feat(transport): Destination worker pool
Implements a per-destination worker pool,
so that connections to the same destination
are not parallelized, but instead queued.
If a queue is full, new messages are immediately
deferred, before mail data is sent from postfix.

Closes: #141

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-26 11:07:34 +02:00
Jagoda Estera Ślązak d3f5412420 feat: switch to aws-lc-rs cryptography provider (#178)
Switches crypto provider to keep
chatmail codebase consistent,
analogous to https://github.com/chatmail/core/pull/8313

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-06 15:28:53 +02:00
l fb5a25939c fix: ignore CNAME records when resolving TXT records (#177) 2026-06-06 16:55:18 +09:00
Andrey 0xdc09 8a60245183 fix(resolver): disable negative caching (#170) 2026-06-02 12:04:32 +02:00
Jagoda Estera Ślązak e9a63222e6 fix(smtp-server): Correct error when EOF while reading DATA (#168)
Log
`Unexpected EoF while receiving DATA!`
instead of
`Malformed DATA line without CRLF ending!`

Fixes: #165

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-06-01 16:27:30 +02:00
l a6361a2194 fix: switch ratelimiter to MonotonicClock (#167)
There is a known bug that `quanta` clock
used by default sometimes jumps back:
<https://github.com/metrics-rs/quanta/issues/111>.
This results in `governor` rate limiter
incorrectly rejecting the messages
even when less than the configured burst size
has been sent.

Switched to standard monotonic clock
which does not have this problem.
I tested that this fixed the problem for me,
chatmail relay test `test_exceed_rate_limit`
stopped failing randomly.

Fixes <https://github.com/chatmail/filtermail/issues/166>
2026-06-01 09:51:33 +02:00
link2xt 847e19546b fix: do not crash if accepting new connection fails
If we run out of file descriptors, we cannot do anything
to accept queued connections, so at least don't crash the process.
Fixes <https://github.com/chatmail/filtermail/issues/139>.
2026-05-14 20:59:59 +00:00
holger krekel 664ad571b6 feat!: remove passthrough options that allowed unencrypted mail to pass
see https://github.com/chatmail/relay/pull/970/ for the related removal of chatmail.ini options
2026-05-14 20:59:13 +02:00
Jagoda Estera Ślązak d74e5b85b3 feat: Improved SMTP error responses (#147)
Fixes: #140

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-05-12 12:37:02 +02:00
holger krekel 3896044f36 fix: return HTTP 200 because madmail expects it, and make sure https is immediately retried when SMTP fails (#153) 2026-05-12 12:13:00 +02:00
l a65e7a1490 fix: Validate mail data (#150)
Do not allow bare CR and LF etc.
2026-05-12 07:00:21 +02:00
holger krekel 36921dd29f fix: advertise 8BITMIME to prevent conversion after DKIM signing (#149)
for bounces postfix sets Content-Transfer-Encoding: 8bit
which causes a quoted-printable conversion when filtermail SMTP does not offer 8BITMIME,
which in turn breaks DKIM verification.
2026-05-12 06:56:11 +02:00
Jagoda Estera Ślązak 5295d175d6 perf(smtp-client): Use pipelining if server advertises support (#146)
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-05-07 15:05:51 +02:00
Jagoda Estera Ślązak 10119033a3 fix(smtp-client): Handle 421 on reused connection (#145)
If a reused connection was closed
in the meantime, open a new connection,
instead of failing immediately.

Fixes #143

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-05-07 14:20:49 +02:00
Jagoda Estera Ślązak d29cbafda4 chore(deps): Upgrade hickory-resolver (#138) 2026-05-05 02:17:21 +02:00
Jagoda Estera Ślązak 0a652e61ee feat: https transport channel (#122)
Transport mode:
Implements an additional mail delivery
channel over HTTPS.

Incoming mode:
Adds a http server listening for
incoming messages delivered over HTTPS.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-05-01 10:30:09 +02:00
Jagoda Ślązak 1b1585eb7d refactor(transport): Explicitly handle RFC7505 null MX
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-28 08:24:27 +02:00
Jagoda Ślązak 21aaea0d92 fix: Implement missing "implicit MX" rule
Implements "implicit MX" as described by
https://datatracker.ietf.org/doc/html/rfc5321#section-5.1

Fixes: #126
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-27 14:44:21 +02:00
Jagoda Estera Ślązak 1e356315da feat(smtp-server): Log malformed SMTP commands (#118)
Closes #110

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-20 13:03:49 +02:00
Jagoda Estera Ślązak dee00ebdcf perf(smtp-client): Cache connections (#117) 2026-04-17 11:37:05 +02:00
Jagoda Estera Ślązak cf64778f71 feat(transport): Remote delivery over SMTP (#104)
Implements a new mode "transport",
that allows filtermail to be used for
remote delivery.

In transport mode, filtermail listens for LMTP
connections, splits messages by domain
and performs delivery to remote MTAs over SMTP.

SMTP client tries to open socket on all resolved
addresses in parallel and uses one that succeeds
the first, fixing the issue described in:
chatmail/relay#900

Extends the built-in SMTP client
with STARTTLS support.

Extends the built-in SMTP server
with LMTP greeting support.

Groundwork required for mxdeliv endpoint
(HTTP channel for MTA-to-MTA communication):
chatmail/relay#900

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-15 22:12:09 +02:00
Jagoda Estera Ślązak ec0413bd5f feat: Log disabled recipients (#113)
Logs disabled recipient addresses
when removing them from RCPT TO.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-15 22:00:42 +02:00
Jagoda Estera Ślązak 05cbf2908c feat: Add experimental option to disable mailboxes (#108)
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-04-01 23:05:02 +02:00
Jagoda Estera Ślązak fb77c5be81 feat(resolver): Enable DNSSEC (#94)
From hickory-resolver docs:
> To enable DNSSEC, enable the dnssec-ring feature.

Related: https://github.com/chatmail/relay/issues/877
Related: https://github.com/hickory-dns/hickory-dns/issues/3519
Closes: https://github.com/chatmail/filtermail/issues/93

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-03-24 08:27:48 +01:00
Andrey 0xdc09 9a4a54cea8 refactor: derive Default for Envelope (#100) 2026-03-16 10:01:52 +01:00
Andrey 0xdc09 49df79bfa0 feat: configurable hosts for listen and reinject (#84)
Adds configurable listen IP and postfix host 
via `filtermail_host` and `postfix_host` chatmail.ini config fields.
2026-03-13 17:04:44 +01:00
Jagoda Estera Ślązak 8dd9436a0d feat!: Remove IP verification for domain-literals (#90)
BREAKING CHANGE: messages using domain-literal
  addresses don't require to match the origin
  SMTP connection IP anymore.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-03-13 12:25:45 +01:00
Andrey 0xdc09 c088cbfe4d refactor: use enum for mode cli arg (#83) 2026-03-05 10:17:37 +01:00
Jagoda Estera Ślązak 82618de311 feat: Check incoming email return address (#72)
If the MAIL FROM doesn't match the From header,
we do not reject the mail, as this can be caused
by e.g. SRS forwarding. Instead, we reset the envelope
address, so it is reinjected as `MAIL FROM:<>`
to prevent sending a bounce message.

Closes #67

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-25 16:20:08 +01:00
Jagoda Estera Ślązak a5c6880ceb refactor: Check if email is encrypted before verifying DKIM (#71)
This way we won't be logging DKIM rejections on messages that
would be rejected anyway due to not being encrypted.

Fixes #69

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-25 16:10:01 +01:00
Jagoda Estera Ślązak 2e1c38466c fix(logs): Log correct address for outbound messages (#70)
Fixes #68

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-25 16:08:41 +01:00
Jagoda Estera Ślązak e1841cb590 fix(logs): Log From address instead of envelope MAIL FROM. (#66)
Fixes #64

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-24 11:58:28 +01:00
Jagoda Estera Ślązak 52208c42b6 fix(dkim): Accept TXT records with escaped quotes (#61) 2026-02-24 08:12:17 +01:00
Jagoda Estera Ślązak 8a1684d488 fix(smtp): Properly handle bounce messages (#63)
Closes #58

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-23 19:45:21 +01:00
Jagoda Estera Ślązak 6145be4108 fix(dkim): Accept TXT records with no v= tag (#62)
Cache at most 3 TXT records instead of trying to find one that includes `DKIM`.

Closes #59

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-23 19:44:30 +01:00
Jagoda Estera Ślązak 54982b1fdd feat: Save rejected messages to /tmp (#55) 2026-02-20 15:38:46 +01:00
l 94f1b29917 refactor: do not copy the mail in memory for DKIM verification (#54)
`String::from_utf8_lossy` always copies the data
for the case when it needs to replace invalid UTF-8,
but we don't want invalid UTF-8 anyway as replacing
invalid UTF-8 characters will break DKIM signature.
2026-02-19 19:06:08 +01:00
Jagoda Estera Ślązak 7d4fac698f fix(dkim): Make simple header canonicalization work properly (#53)
Previously header parsing caused leading whitespaces to be
trimmed in HeaderBody, which resulted in incorrect simple
header canonicalization.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-19 14:33:40 +01:00
Jagoda Estera Ślązak 6e2a37956c chore(tests): Add a way to disable DKIM for tests (#50)
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-17 13:00:31 +01:00
Jagoda Estera Ślązak 4837754245 feat: Support addresses using domain literals (#42)
If the incoming email comes from address that uses
domain literals `[<ipv4>]` or `[IPv6:<ipv6>]`,
skip DKIM verification and instead check IP
alignment with originating IP from XFORWARD
command.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-16 18:25:21 +01:00
Jagoda Estera Ślązak a096d0550f feat!: DKIM verifier (#35)
* feat!: DKIM verifier

This implements a DKIM verification as well as a strict
DKIM signature alignment check with domain in `From`
header address.

Caches the retrieved RDATA using in-memory LRU.

BREAKING CHANGE: incoming messages now require DKIM signatures
  aligned to domain of the `From` header address.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>

* chore(license): License binaries under GPLv3

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>

---------

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-16 09:50:55 +01:00
Jagoda Estera Ślązak cc1604b0b2 feat: Support legacy, pre-OpenPGP packet format (#44)
Support legacy packet format for compatibility with GnuPG.

Closes: #43

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-13 12:31:39 +01:00
Jagoda Estera Ślązak 0ee1e9924c refactor: Use a custom, minimal SMTP client instead of lettre (#33)
This disables the Nagle's algorithm on re-insertion.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-06 11:15:14 +01:00
Jagoda Estera Ślązak 8d18b73681 refactor: Remove unnecessary Arc (#36)
`Arc` around handler configs are not needed,
as they are not shared.

Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-02-05 16:42:06 +01:00
Jagoda Estera Ślązak 23231d462c feat: Configurable rate limiter max burst size (#28)
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
2026-01-28 17:47:48 +01:00