Commit Graph
207 Commits
Author SHA1 Message Date
Wez Furlong 7fffccf410 Add support for generating NDRs
This commit adds some plumbing to facilitate generation of RFC 3464
non-delivery reports and some corresponding glue to enable calling
it from lua.

Examples in the docs that are also added.
2025-09-09 14:12:52 +01:00
Wez Furlong c7cbd99a9f add kumo.inject_message 2025-09-09 10:38:36 +01:00
smsvip 05d4a23b60 Update set_smtpsrv_threads.md
Repair set_smtpsrv_threads documents
2025-08-25 22:20:23 -04:00
Wez Furlong 91884d3892 docs: format 2025-07-26 13:30:00 +01:00
Pankaj RathiandWez Furlong eae61a90fe Add support for custom key names in HashiCorp Vault secrets (#399)
* Add support for custom key names in HashiCorp Vault secrets

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2025-07-25 06:02:21 +01:00
Wez Furlong 9e62a275c5 add tls_required_client_ca esmtp listener parameter
This enables configuring mTLS support in the listener.

Adjust TLS client tests to use this on the sink side and verify
that mTLS works for both inbound and outbound SMTP.

refs: #100
refs: #391
2025-07-24 15:40:49 +01:00
kayozaki 76add2ced5 Adding support for presenting Client cert as part of make_egress_path (#391) 2025-07-24 13:00:27 +01:00
Wez Furlong 7e6ca34e2d new: kumo.fs lua module
The read_dir and glob functions have been logically moved into that new
namespace, leaving deprecated versions of them in the `kumo` module.

A new `kumo.fs.open` function that works similarly to `io.open` is
provided.  This function cooperates with the kumo async io scheduler
and won't block it if the filesystem is under pressure.

It returns file handles that are simlar to the builtin lua file handle
objects, but do not support formatting or parsing of writes or reads
respectively: the calling code is responsible for that.  The rationale
for this difference is that is that lua's semantics for those functions
are frankly a bit weird and are hard to replicate precisely.
2025-07-23 16:51:06 +01:00
Wez Furlong d9a2392ccb allow setting destination smtp port via mx_list 2025-07-21 12:30:29 +01:00
Mike Hillyer 58e9770206 We miss you Mister Rogers. 2025-07-18 12:11:14 -04:00
Wez Furlong e0db075d5f docs: kumo.disconnect
kumo.disconnect was added as part of an earlier commit (to facilitate
some testing), but without any docs.

This commit adds docs for it!
2025-07-07 18:35:46 +01:00
Wez Furlong 42bf5c5e61 docs: adjust reference to improve search terms
We've been hoping that mkdocs-material will ship the much anticipated
search enhancements for some time, but it's time to recognize that
we need to do something to improve the search results with how
things work right now.

This is a big commit that changes the titles of the various pages
from the code-annotated synopsis to just the name of the function.

This makes it much easier now to match things like `kumo.reject`
directly, but `reject` remains awkward to find.

I think this is the best that we can do at this time.

A few functions have been annotated with the `status: deprecated` to
show as deprecated in the toc/nav (shows with a little trash can next
to the name).
2025-05-16 14:02:19 -07:00
Wez Furlong b0c6b1cf6a smtp_dispatcher: retry more aggressively in transport-error-ish scenarios
Some sites are non-conforming in their behavior when they have a policy
that issues a transient failure and then snips the connection without
explicitly issuing a 421.

This can cause "splash damage" where a message is transiently failed
and the connection snipped "disgracefully" and a subsequent message
that is due to go out on that same established connection encounters
a transport error when the RSET part of the pipeline is sent.

This commit provides methods on the ClientError and Response types
to help reason about whether the response might be specifically
about the message being delivered, vs. more of a transport error.

The gist of this check is that timeouts and transport level stuff
where there is no protocol level response are not considered to
be due to the message.  Protocol level responses prior to MAIL FROM
are similarly considered to be more like transport errors.

The functional change in this commit is:

* If we get a transport-ish error and we have more candidate hosts
  available in the connection plan, then after logging a
  TransientFailure for the error we just encountered, we'll push
  back the message to be tried again on the next connection that
  we open in the current session.

* For timeout errors specifically, this behavior is gated behind
  a try_next_host_on_timeout boolean option.
2025-05-08 10:41:06 -07:00
Wez Furlong c3dff7e2c8 docs: update for latest release 2025-05-06 18:24:15 -07:00
Wez Furlong b29689af74 docs: memoize: allow_stale_reads 2025-05-06 05:55:44 -07:00
Wez Furlong 507822f1c9 docs: fmt 2025-05-06 05:55:34 -07:00
Wez Furlong fedd2959b6 enhance log_arf, log_oob to support LogThenDrop
It is common to want to express that incoming reports should
be logged, but not relayed.

This commit facilitates that by expanding `log_arf` and `log_oob`
to allow more than just a simple boolean value.

We now support both LogThenRelay and LogThenDrop as dispositions
for an incoming report, as well as Ignore to not care about the
report content.

For the LogThenDrop case we'll log only the incoming OOB or Feedback
record to the logs and then discard the incoming message.

For LogThenRelay we'll log the incoming OOB/Feedback report as well
as enqueue the message and log a Reception and, subsequently, records
for its delivery attempts.

The previously supported boolean values are mapped to `Ignore` (false)
and `LogThenRelay` (true), respectively: their behavior is the same as
in prior releases.

The integration test and smtp server tracing infra has been enhanced a
bit to support extracting these new disposition states from the tracer
during the integration test.
2025-05-05 08:25:40 -07:00
Wez Furlong b8310da8be docs: add warning about logging headers
TL;DR: you can easily halve your system performance by logging headers
vs. logging meta.

This is one of those things that is easy to overlook or forget,
but: whenever you need to operate on the message data, rather
than its metadata, the aggregate cost is high.

In this case, we were recently troubleshooting a system where
the CPU was bogged down and we traced it to the logging configuration: a
number of message headers were being logged in a configuration that
made heavy use of throttles and limits in its traffic shaping, and
thus had a large number of Delayed and TransientFailure events being
written to the logs.

When logging headers, each one of those events requires loading
the message from the spool and parsing out the headers.  When the
average message size is ~100KB this imposes a notable overhead
on the CPU and IO utilization of the system.

What we recommend instead of logging headers directly is capturing
the information that you want to log into the message metadata
at the time that the message is received.

The message meta is usually already loaded, but is also typically
much smaller and easier to decode than the full message content
in the cases where it is not loaded.

As a result, it is much cheaper to log meta than to log headers.

This commit adds some warnings and cross links to help folks
be aware of this, and to generally navigate related meta and logging
topics more easily via tags.
2025-04-25 05:52:44 -07:00
Wez Furlong 18e510ebe2 ready_queue: introduce dispatcher_wakeup_strategy and maintainer_wakeup_strategy
These allow optionally reducing how aggressively the dispatcher and
maintainers will be awoken when message(s) are submitted to the ready
queue.

The default behavior remains the same; the new thing here is the
ability to make it more relaxed, which should reduce some CPU
overheads for very busy systems with many queues.

Making things more relaxed does introduce a possibility for higher
outbound latency in some edge cases with low or bursty traffic.
2025-04-16 15:19:27 -07:00
Wez Furlong 3b14587192 fix delayed shutdown for non-smtp delivery handlers
Occasionally we'll have someone report that systemd timed out
and sigkill'd their kumo on shutdown.

One possible scenario for this is a lua delivery handler that
is taking too long, presumably because the other end of it
(eg: webhook or other custom endpoint) is not responding in
a timely fashion.

The way that we handle shutdown is that we compute a maximum
theoretical timeout value by summing up all of the smtp client
timeout values.  Some of those can be several minutes in
duration because the are using default values derived from
a very conservative set of values suggested by the SMTP
RFCs from the '70s.

Those obviously should not apply to a custom delivery handler,
but also, in the context of an established SMTP session, we
should not add in the connection-establishment-specific values
when we're just waiting for a per-message send.

This commit addresses this situation on two fronts:

* Introduce a new system_shutdown_timeout value that allows the
  user to conveniently express their desired timeout value
  in a single option.  This is *not* set by default!
* The default value for system_shutdown_timeout is computed by
  summing the per-message-delivery smtp timeout options, which
  is a much more reasonable, and more importantly, shorter than
  our 300s TimeoutStopSec value in kumomta.service
2025-04-02 14:21:31 -07:00
Wez Furlong ff7f9eb666 move readyq maint into its own thread pool
Previously, we'd use the qmaint pool to spawn both the scheduled
and ready queue maintenance tasks.

This commit splits them apart in order to avoid the potential for
cross-task contention on the same threads if a scheduled queue
and ready queue pair are communicating with each other.
2025-04-02 10:36:46 -07:00
Wez Furlong 4b33354dee allow overriding available_parallelism value
We recently observed a system running on an over-committed VM that
reported 4x the actually available parallelism.

Since we scale our thread pool sizes from this value, it resulted
in an extra-over-committed configuration for kumod.

You may now set KUMO_AVAILABLE_PARALLELISM in the environment to
override the value that we see both interally and expose via
the lua function with the same name.
2025-04-01 06:37:12 -07:00
Wez Furlong e422f56b5c smtp_server: add smtp_server_get_dynamic_parameters event
This helps to deploy IP-based virtual service.
2025-03-23 08:24:28 -07:00
Wez Furlong 8253417576 smtp_server: add meta parameter to start_esmtp_listener
This allows pre-defining connection metadata values.  When coupled with
`peer` and/or `via`, these can be done based on the corresponding
addresses associated with the session.

closes: https://github.com/KumoCorp/kumomta/issues/355
2025-03-22 11:13:22 -07:00
Wez Furlong a7c98a7d0f smtp_server: add via matching parameter to start_esmtp_listener
Similar to the peer option, but this one matches based on the
local address, giving a bit more flexibility for virtual hosting.
2025-03-22 11:07:19 -07:00
Wez Furlong 3e9bc5a946 smtp_server: introduce new peer matching option to start_esmtp_listener
This allows crafting peer-address-specific values for a listener.
2025-03-22 10:35:42 -07:00
Wez Furlong 9de685aa54 smtp_server: refactor tls_config
The motivation here is to remove tls_config from EsmtpListenerParams
to make some future configuration changes easier, so this commit
moves that simple cache out to an explicit lru ttl cache.

This has the welcome side effect of enabling periodic reloading
of the tls parameters, which in turn makes it a hands-off process
for updating certificates: we no longer require the service to
be restarted for that.
2025-03-22 09:18:38 -07:00
Wez Furlong 19341dc710 lruttl: add params to control timeout and retry on sema timeout
These are hooked up only for memoize at this time.  No default
behavior is changed by this commit, but you can optionally
specify these parameters in order to change the behavior.
2025-03-21 16:56:12 -07:00
Wez Furlong 337b4e33a8 docs: update for stable 2025.03.19-1d3f1f67 release 2025-03-20 07:28:32 -07:00
Wez Furlong 6d17a0a453 docs: mention mta-sts and dane on the enable_tls page 2025-03-17 08:52:10 -07:00
Wez Furlong c2444b6266 add expiry to per-msg scheduling overrides
This commit allows setting a per-message `expires` timestamp
via msg:set_scheduling (and thus msg:import_scheduling_header).

The expiration takes precedence over max_age; max_age will be
ignored for messages that have configured and expiration time.

The expiration time is independent of the other scheduling
restrictions.
2025-03-15 07:18:13 -07:00
Wez Furlong 9286394e72 docs: fixup list bullets for source_selection_rate 2025-03-11 09:54:14 -07:00
Wez Furlong 6ef73a096e docs for source_selection_rate 2025-03-11 09:46:58 -07:00
Wez Furlong 0fe856516c add kumo.log_(error|info|warn|debug) functions
These log their arguments to the diagnostic log.
2025-03-06 17:15:15 -07:00
Wez Furlong 85b922d40b add kumo.set_lruttl_cache_capacity function
This allows configuring the capacity limit for internal caches.
2025-03-05 08:50:11 -07:00
Wez Furlong b2887cb7b8 data_processing_timeout: increase default to 5 minutes
I worry that 1 minute might be too short to be universally good,
particularly as a change in behavior from an earlier build: going from
no timeout to 1 minute could be super surprising and un-welcome.

Let's bump this up to 5 minutes which more closely matches the
default for DATA in the base SMTP RFC.
2025-03-04 16:23:16 -07:00
Wez Furlong fa1857be98 docs: add data_processing_timeout 2025-03-04 16:23:15 -07:00
Wez Furlong c5014f9594 docs: add some rocksdb tuning options to the docs 2025-03-04 16:23:14 -07:00
Wez Furlong df8aa10ad1 docs: split define_spool docs into separate pages 2025-03-04 16:23:14 -07:00
Wez Furlong 3071fe9701 add shrink_policy queue config option
This allows reducing how much of a message is freed when it is
delayed.
2025-02-21 17:15:52 -07:00
Wez Furlong 3805afdcc1 docs: fixup list presentation for (low|no)_memory_reduction_policy 2025-02-21 14:32:36 -07:00
Wez Furlong a1fb96dfc0 add (low|no)_memory_reduction_policy options
These provide more control over the memory vs spool IO tradeoff
when memory is short.
2025-02-21 10:48:14 -07:00
Wez Furlong 7cf6b93783 memory: allow setting soft and low memory limit/thresholds
If you have a lot of RAM, using only default percentages could
potentially leave some RAM unused.  These lua functions
allow more precise control over the limits.
2025-02-20 12:06:12 -07:00
Ryan Bonnell d1632059ca Remove duplicate word 2025-02-08 07:29:41 -07:00
Wez Furlong 0ab606cfee memoize: make epoch-based invalidation optional
It is not always desirable to invalidate with the epoch,
so allow opting in instead of always invalidating that way.
2025-02-06 11:06:25 -07:00
Wez Furlong 4ed60d30a1 docs: update for release 2025-01-29 17:05:37 -07:00
Wez Furlong ea8f2be678 docs: add weird period example to throttle docs 2025-01-29 09:45:04 -07:00
Wez Furlong 87e0939f43 throttle: expose max_burst throttle spec
This was always present, it just wasn't something we provided a syntax
to specify.

max_burst allows you to control how quickly your throttle budget will
be consumed over the throttle time period.

The default max_burst is equal to the limit you specify, allowing
the full budget to be instantaneously consumed.

refs: https://github.com/KumoCorp/kumomta/issues/326
2025-01-29 09:22:57 -07:00
Wez Furlong e474516b01 add reconnect_strategy option
This controls what we do in an smtp session when we experience a
disconnect during message sending; do we give up on the session,
continue with the connection plan, or try to connect to the same
host again and continue sending any additional messages there?
2025-01-24 13:43:49 -07:00
Wez Furlong 01c52eef03 docs: update for 2025.01.23-7273d2bc release 2025-01-23 13:49:35 -07:00