I’m trying to get the complete message data (including body and attachments) out to another system in order to save it there for a period of time. Log Hooks don’t seem to be able to send out the complete data, so I tried routing the message via a HTTP request as explained here Routing Messages via HTTP Request - KumoMTA Docs :
kumo.on('make.message_saver', function(domain, tenant, campaign)
local client = kumo.http.build_client {}
local saver = {}
function saver:send(message)
-- Make the request
local response = client
:post('http://192.168.0.100:4242/message')
:header('Content-Type', 'text/plain')
:body(message:get_data())
:send()
-- and handle the result
local disposition = string.format(
'%d %s %s',
response:status_code(),
response:status_reason(),
response:text()
)
if response:status_is_success() then
-- Success!
return disposition
end
-- Failed!
kumo.reject(400, disposition)
end
return saver
end)
kumo.on('get_queue_config', function(domain, tenant, campaign, routing_domain)
return kumo.make_queue_config {
protocol = {
custom_lua = {
constructor = 'make.message_saver',
},
},
}
end)
This works, but two things have changed compared to when I didn’t have this code in my config:
- I’m receiving an additional Log Message with Type
Deliverywhich with itssiteparameter set tounspecified->example.com@lua:make.message_saver. Is it possible to prevent the log hook from sending these? - I’m not receiving a bounce log message even though the Recipient email address domain doesn’t have a MX record (e.g. sending to someone@example.com). I assume this is because the message is actually being delivered to somewhere (via the
message_saverfunction), which is also why I’m receiving theDeliverylog message in (1). Is there a way to prevent this behavior?