For testing purposes, I’ve installed KumoMTA and I’m currently running some tests
My next goal : Basically, I would like to ensure that a message received on a specific Listener is enriched with a variable to be used later for certain routing operations.
I saw that this could be done within smtp_server_message_received using conn:get_meta('received_via'), but I would prefer to set this variable on the listener to keep everything organized.
There is a way to set a “context” key=value at listener session or is there anything I’m overlooking or a better way to achieve this?
Something like ( no way for the “customer” to add extra headers ) :
there isn’t a way to statically declare it that way, but you could implement smtp_server_ehlo - KumoMTA Docs and then use a simple map to read the received_via and then assign your customer id meta value back to the connection metadata.
So, something like that I think… I’ll try to see if I can get what I want
kumo.on('smtp_server_ehlo', function(domain, conn_meta)
-- Get the 'received_via' value
local received_via = conn_meta:get_meta('received_via')
-- Define a map (table) for 'received_via'
local received_via_map = {
["10.0.0.1:25"] = "123",
["10.0.0.2:25"] = "456"
}
conn_meta:set_meta('customer', received_via_map[received_via])
end)
Hi Wez, my test works! I’ll leave for ( eventually ) reference.
kumo.on('smtp_server_ehlo', function(domain, conn_meta)
-- Get the 'received_via' value
local received_via = conn_meta:get_meta('received_via')
-- Define a map (table) for 'received_via'
local received_via_map = {
["10.0.0.1:25"] = "Tenant2",
["10.0.0.2:25"] = "Tenant3"
}
conn_meta:set_meta('customer', received_via_map[received_via])
end)
kumo.on('smtp_server_message_received', function(msg, conn_meta)
msg:set_meta('tenant', conn_meta:get_meta('customer'))
end)
in /opt/kumomta/etc/queues.toml
...
[tenant.'Tenant2']
# Which pool should be used for this tenant
egress_pool = 'pool-2'
[tenant.'Tenant3']
# Which pool should be used for this tenant
egress_pool = 'pool-3'
...
I don’t know if there are better ways to do it, but this exercise is gradually allowing me to better understand the potential of KumoMTA. Kudos to everyone!