My Lua skills are not top notch and I could not find a full answer in the help. If I want to remove mail from a sender domain which I don’t want to send anymore.. Would this piece of code then nuke all that mail silently? I do have mail with different subdomains.. Is there a way to regex match… there probably is, but I did not find it yet in the lua tutorials I quickly skimmed.
kumo.on('requeue_message', function(msg)
local queue = msg:get_queue_name()
local mydomain = msg:from_header().domain
-- domain should be an array
if mydomain == "news.domainname.com" and msg:num_attempts() >= 1 then
-- move to nill queue and thus nuking it?
msg:set_meta('queue', 'nill')
end
end)
That looks sane theoretically but requeue_message only works on currently trans failed messages. It will not do anything to messages that are at rest in the queue.
You can’t msg:set_meta('queue', 'null') after reception, because there isn’t actually a null queue, it is a special label used at reception time to skip inserting into any queues.
re: regex, lua has built in matching functions, but the syntax is… unusual. We have our own compile - KumoMTA Docs that uses the more familiar pcre style regex syntax
I did do this as suggested but I am not seeing bounces (in the logs) on the domains I want to clear. So probably my condition is not right. Is this about right?
kumo.on('rebind_message', function(msg, data)
local mydomain = msg:from_header().domain
-- domain should be an array
if mydomain == "newsletter.domain.com" then
kumo.reject(500, "don't send this any more")
end
end)
Then I did: kcli rebind --everything --trigger-rebind-event --reason "Need to cleanup some domains"