Hi all,
I need help with modifying the Message-ID header in KumoMTA. Specifically, I want to set the Message-ID to be a combination of msg:id() and the domain from the “From” address.
Below is the code I wrote to achieve this:
kumo.on(“smtp_server_message_received”, function(msg)
– Extract domain from the sender’s address
local from_address = msg:from_header() – Sender’s address
local domain = from_address:match(“@(.+)$”) – Extract domain after ‘@’
if domain then
local message_id = "<" .. msg:id() .. "@" .. domain .. ">"
msg:append_header("Message-ID", message_id)
kumo.log.info("Added Message-ID: " .. message_id)
else
kumo.log.error("Failed to extract domain from from_header")
end
end)
However, when I run the code, I encounter an error. Could someone please help me identify what might be going wrong or offer suggestions on how to fix it?
=== smtp_server_message_received: Error: runtime error: [string “/opt/kumomta/etc/policy/init.lua”]:239: attempt to index a nil value (global ‘message’)
stack traceback:
[string “/opt/kumomta/etc/policy/init.lua”]:239: in function <[string “/opt/kumomta/etc/policy/init.lua”]:231>
Thanks in advance!