Is there a way to set the “Message-ID” header using Kumomta? Currently, I am using the following code to add the “Message-ID” header, but it is not working:
The email ends up in a bounced status with the error ‘This message is not RFC 5322 compliant. There are multiple Message-ID headers. To reduce the amount of spam sent to’.
Hey there @winsome-lion, thanks for posting. Please read the “Troubleshooting” and “How to Ask for Help” buttons below. If you would like a 1:1 support session from the KumoMTA team, details are at the “Book a Support Session” button below.
kumo.on('smtp_server_message_received', function(msg, conn_meta)
local messageIdHeader = msg:get_first_named_header_value('Message-ID')
if messageIdHeader then
if not string.match(messageIdHeader, "^<.+@" .. msg:from_header().domain .. ">$") then
msg:remove_all_named_headers('Message-ID')
msg:append_header('Message-ID', '<' .. msg:id() .. '@' .. msg:from_header().domain .. '>')
end
else
msg:append_header('Message-Id', '<' .. msg:id() .. '@' .. msg:from_header().domain .. '>')
end
end)
I make a check if message-id is already present and has the correct format, if not i remove it, then add a new correct one.
Here, you will find the methods you can use to operate over the message: https://docs.kumomta.com/reference/message/
Hope it helps.
In my case, the client was setting the message id, before reaching kumo, and I was also setting the message-id, so i had to add the check, since the client is sending a good message id, I leave it as is. I guess @winsome-lion is also adding a message id, ending up with 2 message id headers, therefore getting a reject.
@yearning-hyena Currently i’m not setting any message id header, but when it reaches the gmail mail box, there is a default message id in it. i’m attaching the screenshot