Commit Graph
3285 Commits
Author SHA1 Message Date
Wez Furlong 550dca47c1 smtp_server: improve cleanup for partially failed transaction
If we already saved one or more messages that were split out
of a multi-recipient transaction, and then the subsequent save
fails, we would previously leave those earlier messages saved
in the spool and deliver them despite reporting a failure back
to the client.

This commit removes them from the spool and logs a Bounce record
for them.

This is still not an ideal outcome, but it will at least not
send a message for which we haven't claimed responsibility.
2025-10-07 07:53:15 +01:00
Wez Furlong 794113f0b0 smtp_dispatcher: add max_recipients_per_batch
This sets a client side shaping control to manage the maximum number of
RCPT TO commands issued in a single transaction.
2025-10-07 07:53:15 +01:00
Wez Furlong f968935315 add smtp_server_split_transaction event
This provides full control over how an incoming smtp transaction
will be split into batches.
2025-10-07 07:53:15 +01:00
Wez Furlong b157e2f617 add smtp_server_data event for per-txn message validation
Great for doing content scanning and recipient list modification!
2025-10-07 07:53:13 +01:00
Wez Furlong db5ebb88a7 message: expose recipient list to lua api
message:recipient() may now return an array style table
holding the recipient list, if there is more than a single
recipient on the message.

Since this can be somewhat ambiguous/frustrating to work with,
there is now also a message:recipient_list() that will always
return an array style table, even if it holds just a single
element.

The included helpers have been updated to use `message:recipient_list`.

message:set_recipient() will now optionally accept an array
style table holding the recipient list to be set.
2025-10-07 07:52:58 +01:00
Wez Furlong 18e55a6e91 smtp: handle "too many recipients" status more appropriately
This commit adds a test for exceeding the number of recipients
allowed in a transaction and fleshes out our handling of that
status so that we will immediately try the remaining recipients
of the batch, without delaying the message by eg: 20 minutes
in the default retry parameters.

As part of this, I noticed that we were returning the wrong
smtp status code in our server implementation, so this
commit fixes that up.
2025-10-07 07:52:58 +01:00
Wez Furlong 888928b60f WIP: basic batch relaying and end-to-end test
This makes a first pass over relaying a batch, with a test
to prove that it worked.

The logic in the smtp client likely needs to be enhanced
to handle hitting recipient-per-transaction limits; tests
for various scenarios need to be added in follow-on commits.
2025-10-07 07:52:57 +01:00
Wez Furlong 4255e02ffa WIP: smtp_server: scaffolding to support for batching by domain
This adds a `batch_handling` parameter that optionally allows splitting
up a recipient batch based on the destination domain.

The system does not yet have any support for correctly delivering such a
batch.
2025-10-07 07:52:57 +01:00
Wez Furlong 9079a9e569 WIP: more multi-recipient type changes
This commit updates the type signatures of some key structures
to allow for the possibility of a Message having multiple recipients:

 * Message (continuing from previous commit)
 * JsonLogRecord
 * MessageInformation

Some logic has been updated to account for multiple recipients,
but critically, nothing in the core will generate them, and none
of the queue management or delivery infrastructure is aware
of recipients beyond the first.
2025-10-07 07:52:57 +01:00
Wez Furlong 055a2d0086 message: allow for multiple recipients in metadata 2025-10-07 07:52:56 +01:00
Wez Furlong 206dc7c7fa optionally detect legacy 8-bit during check-fix 2025-10-07 07:50:46 +01:00
Wez Furlong 981de67f1c docs: update for 2025.10.06-5ec871ab release 2025-10-07 07:38:10 +01:00
Sophia J. TurnerandSophia Turner 5ec871ab04 Add support for dmarc pct (#424)
* Add support for dmarc pct
* address feedback

---------

Co-authored-by: Sophia Turner <sophiajt@users.noreply.github.com>
2025-10-06 23:26:16 -07:00
Wez Furlong 53a92c5cda ci: try to reduce flakiness for the lapin integration tests
This seems to flake out reasonably regularly in CI on PRs.
Let's see if adjusting the ordering of things a little bit
encourages a less flakey result.
2025-10-06 20:12:19 +01:00
Wez Furlong 307d0b3093 docs: changelog for #423
closes: https://github.com/KumoCorp/kumomta/issues/423
2025-10-06 19:41:53 +01:00
Wez Furlong f28aef0ab0 rfc5321: fixup norun attribute on doc comment 2025-10-06 07:02:19 +01:00
Wez Furlong 4ba41290a6 docs: format and fixup whitespace 2025-10-06 07:02:18 +01:00
Wez Furlong dba45cfa28 logging: allow * to match meta names
This uses the same scheme as allowed for matching header names
in logging.
2025-10-06 07:02:18 +01:00
Wez Furlong 38fceae7ea spf: apply dns lookup limits
Noticed that we weren't apply the limits specified by
https://datatracker.ietf.org/doc/html/rfc7208#section-4.6.4
2025-10-05 09:50:45 +01:00
Wez Furlong 2654ab373a spf: implement p macro
Refactor the ptr logic so that it can be re-used for 'p' macro
expansion.

refs: https://github.com/KumoCorp/kumomta/issues/423
2025-10-05 09:05:53 +01:00
Wez Furlong 2eb21bea96 spf: implement h and r macros
refs: https://github.com/KumoCorp/kumomta/issues/423
2025-10-05 08:14:55 +01:00
Wez Furlong 34622edbd2 spf: allow for underscores in domain names when including
Use the more relaxed form of Name parsing so that domains
with underscores (which are in common use with email) do
not generate an error at runtime when processing spf
include rules.
2025-10-05 07:02:46 +01:00
Wez Furlong d6e0dcbe58 spf: allow for extraneous spaces in spf records
They are present in the real world and shouldn't block
us from parsing those records.
2025-10-05 06:41:50 +01:00
kay ozaki e97ca47816 support ip4, ip6 with no subnet 2025-10-04 07:43:59 +01:00
Wez Furlong d4a79a0f27 rustfmt 2025-10-03 20:28:00 +01:00
Tom Mairs 873f9e524d Update sample code 2025-10-03 20:27:23 +01:00
Wez Furlong 0e9e9f6d44 http_server/auth: clarify Missing Authorization header message
It feels reasonable to include the peer ip in the error message,
to aid in debugging trusted host access
2025-10-03 20:09:49 +01:00
Wez Furlong 5228f794bb xclient: capture original via/from address in context
I can see someone wanting to know the raw physical connection
info at some point, regardless of the adjusted xclient values,
or in the future, the proxy protocol adjusted values.
2025-10-03 20:03:14 +01:00
ncai ce743133b0 fix typo in doc 2025-09-30 07:35:32 +01:00
Sophia Turner 19e80001cd Address feedback 2025-09-30 07:13:12 +01:00
Sophia Turner 3dedcd3226 add working dmarc alignment tests 2025-09-30 07:13:12 +01:00
Sophia Turner 1853f1be88 Initial DMARC support 2025-09-30 07:13:12 +01:00
Wez Furlong d9d3d14e3e enable XCLIENT support
Hooks up the parsed XCLIENT command to the smtp server.
We support just the address changing attributes; we don't
do anything special with the NAME attribute, and I'd like
to think a lot more about authentication before allowing
messing with the LOGIN attribute.

After applying changes to the metadata in the connection,
take care to re-evaluate the listener parameters and
dynamic parameters so that `via` and `peer` blocks can
match the new configuration.
2025-09-26 09:36:15 +01:00
Wez Furlong a806865e9a rfc5321: add support for parsing XCLIENT commands
This adds support only to the parser for recognizing an XCLIENT
command.

It does not implement XCLIENT in either the client or the server.
2025-09-25 14:57:09 +01:00
Wez Furlong 90dd172f6c wrap up 8BITMIME and SMTPUTF8 support
Finishes up support for these extensions by adding a send-time
check and error for the case where we have 8 bit content and
the appropriate extension is not advertised by the next hop.

A shaping option is provided to bypass this, both to facilitate
testing and as a way to bypass it for situations where the
operator knows best.

closes: https://github.com/KumoCorp/kumomta/issues/327
2025-09-25 12:37:11 +01:00
Wez Furlong 62dd76d3ae expand test_apply_supplemental_header.lua a bit
I meant to include an example to validate passing and parsing
the trace header parameters, so here it is.
2025-09-25 09:09:21 +01:00
Wez Furlong 33e1883d79 add kumo.apply_supplemental_trace_header
This allows manual and conditional control over whether and how this
header is added to a message.
2025-09-25 09:02:41 +01:00
Wez Furlong 6fdffa53e3 expose hostname and received_via for http injections
To facilitate this we need to feed the `AppState` down through
the Router more generally, and expand it to grab a copy of the
http listener parameters.

closes: https://github.com/KumoCorp/kumomta/issues/417
2025-09-25 08:37:06 +01:00
Wez Furlong c86b8325a6 ndr: don't try to generate one for the null sender 2025-09-25 07:18:46 +01:00
Wez Furlong 85dc29b42d mailparsing: add more context when headermap accessors fail
Introduce a couple of error variants that indicate that the
failure was during parsing of a specific named header.

This makes it easier to understand the source of an issue.
2025-09-25 06:59:34 +01:00
Wez Furlong 607afd69a1 kumo-prometheus: fix warning
Newer versions of rust warn about the extra parens used here.
2025-09-24 14:57:42 +01:00
Wez Furlong 5a1efc0c8c rustfmt 2025-09-18 20:09:48 +01:00
Wez Furlong e203e158af fixup test build
This is weird; I can't reproduce the CI failure locally, even with an
updated version of rust, but the diagnostic in CI points to
https://github.com/rust-lang/rust/issues/131114 which suggests that
str::from_ut8 is unstable, but buried within it is the mention that
std::str::from_utf8 is OK to use.

Let's see if this does the job?
2025-09-18 19:50:37 +01:00
Wez Furlong c2b9b6b335 smtp_dispatcher: remove unused type
This was added in 76add2ced5 (#391)
but never actually hooked up.
2025-09-18 19:49:03 +01:00
Wez Furlong 29a99b66b8 mailparsing: preserve supplemental Content-Type parameters on rebuild
When performing a rebuild, we'd build completely new RFC 2045/RFC 2047
mime headers.

However, sometimes there are "load bearing" additional parameters in
the source part that are important to preserve; for example, calendar
invites include a `method=REQUEST` parameter that is important to
pass through in order for the invitation to correctly interface with
the recipients calendar.

This commit adjusts the rebuild logic to merge in any parameters
that we didn't set in the basic rebuild.
2025-09-18 16:13:50 +01:00
Wez Furlong eb54cc74d9 proxy-server: raise NOFILE soft limit to match hard limit
This makes the startup behavior consistent with kumod and tsa-daemon,
which can help with "Too many open files" errors in systems without
any explicit tunings for the proxy server.

It is still a good idea to explicitly tune that value up, and it is
something we should put into a systemd unit when we get around to
shipping one of those for the proxy server (#188)
2025-09-18 15:54:18 +01:00
Wez Furlong 220edf24b4 fix doc link 2025-09-18 15:27:05 +01:00
Wez Furlong b615646e84 mod-encode: be more relaxed about excess baseXX padding
The implementation of these encodings in the data-encoding crate is
overly strict when extraneous/excess padding is used, presenting
problems from the perspective of Postel's law especially in the context
of email: there are base64 encoders widely deployed that can produce
extraneous padding that is otherwise harmless but which will raise an
error from this crate.

This commit works around this by manipulating the encoding context
to remove the padding requirement, as well as the padding, and
decodes the input without padding.
2025-09-18 15:22:04 +01:00
Wez Furlong f4b2ff4b4e logging: emit additional event_time and created_time fields
We made the unfortunate choice to emit the `timestamp` and `created`
fields as unix timestamps with no sub-second precision.

This commit causes us to emit the full-resolution timestamps that we
already have as additional event_time and created_time fields
in the JsonLogRecord, without internally duplicating those fields.

refs: https://github.com/KumoCorp/kumomta/issues/405
2025-09-12 15:28:22 +01:00
Wez Furlong 91c0c2ac57 mailparsing: fallback to Content-Type::name for attachment name
Adjusts how we resolve the attachment name when processing mime
attachment parameters:

* First check Content-Disposition::filename
* Then check Content-Type::name

De-couple parsing out the `Content-Id` header from having
`Content-Disposition`.

In the lua bindings; remove the synthesized filename fallback;
we now just leave it nil to match the rust logic.
2025-09-10 10:42:48 +01:00