Files
kumomta/docs/reference/events/http_message_generated.md
T
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

38 lines
1.2 KiB
Markdown

# http_message_generated
```lua
kumo.on('http_message_generated', function(message) end)
```
Called by the HTTP injection API endpoint after generating a message, but prior
to injecting it into the queue.
The event handler will be passed a [Message](../message/index.md) object.
The HTTP injector does not add a `Received` header, but it will pre-set the
following meta values in the message:
* `"http_auth"` - will hold either the authenticated username or the peer IP
address that satisfied the authentication check for the endpoint.
This event is the best place to carry out a number of important policy
decisions:
* DKIM signing via [message:dkim_sign](../message/dkim_sign.md).
* Assigning the `"campaign"`, `"tenant"` and/or `"queue"` meta values via [msg:set_meta](../message/set_meta.md)
You may use [kumo.reject](../kumo/reject.md) to raise an error to prevent this
message from being queued for delivery.
```lua
kumo.on('http_message_generated', 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)
```