Files
kumomta/docs/reference/events/smtp_server_message_deferred_inject.md
T
Wez Furlong 5f19f7ce04 add deferred_queue option to the smtp listener
This option should be used with caution, and ideally only
for trusted networks.

The purpose is to absorb the latency of post-DATA processing
and hide it from the trust injector.

It defers processing that would normally happen in smtp_server_message_received
and instead will, at some (ideally) near-future time trigger an
smtp_server_message_deferred_inject event instead.

This will marginally increase your average injection latency but should
clamp your worst case injection latency much lower because the outliers
will not happen inline with the injecting client.
2024-12-16 11:27:40 -07:00

1.7 KiB

kumo.on('smtp_server_message_deferred_inject', function(message, conn_meta))

{{since('dev')}}

When deferred_queue is enabled, this is called by after accepting the message data and responding to the client.

If the client issued multiple "RCPT TO" commands in the same transaction, each one will result in a separate message being created, and this event will be triggered for each of them.

The event handler will be passed a Message object. The Message will always have a Received header prepended that captures trace information about the sender.

The conn_meta parameter represents the connection metadata, but it is synthesized from the metadata in the message. It is provided as a type-compatible way to reference the metadata for functions like SPF and DMARC that accept connection metadata. While it is possible to update/set values in this metadata object, they will not persist once the smtp_server_message_deferred_inject event handler returns. See Connection Metadata for more information.

You can and should use this event to process things that you would normally have done in the smtp_server_message_received event handler, such as:

kumo.on('smtp_server_message_deferred_inject', function(msg)
  local signer = kumo.dkim.rsa_sha256_signer {
    domain = msg:from_header().domain,
    selector = 'default',
    headers = { 'From', 'To', 'Subject' },
    key = 'example-private-dkim-key.pem',
  }
  msg:dkim_sign(signer)
end)