Configuring Sending IP's Based On Recipient

I want to configure my sending IP’s as such that if my mails are delivered to @yahoo.com then it should take a specific IP to send mails otherwise it should rotate IP’s normally.

Hey there @natural-frog, 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.

Hi @natural-frog this is a very good question, i was just thinking about a feature like this, on my smtp server.
This is just a suggestion:

kumo.on('get_egress_pool', function(pool_name)
    local pool = conn:query('GET', 'tenant_pools:' .. pool_name)

    if pool then
        local decoded_pool = kumo.json_parse(pool)
        local name = decoded_pool.name
        local entries = decoded_pool.sources
        local egress_entries = {}

        for _, entry in ipairs(entries) do
            table.insert(egress_entries, entry)
        end

        return kumo.make_egress_pool {
            name = name,
            entries = egress_entries,
            ttl = '10 minutes'
        }
    end

end)

kumo.on('get_queue_config', function(domain, tenant_domain, campaign)
    -- somehow determine egress_pool name by destination domain
    -- check if domain param of this event is actually the destination domain
    local egress_pool_name = 'obtained_by_destination_domain'
    return kumo.make_queue_config({
        max_age = '72 hours',
        retry_interval = '4 hours',
        max_retry_interval = '24 hours',
        egress_pool = egress_pool_name -- here
    })
end)
kumo.on('get_egress_source', function(source_name)
    local source = conn:query('GET', 'tenant_sources:' .. source_name)
    if source then
        local decoded_source = kumo.json_parse(source)
        return kumo.make_egress_source {
            name = source_name,
            source_address = decoded_source.ip,
            ehlo_domain = decoded_source.ehlo_domain,
            ttl = '10 minutes'
        }
    end
end)

check
https://docs.kumomta.com/reference/events/get_queue_config/
https://docs.kumomta.com/reference/kumo/make_queue_config/
https://docs.kumomta.com/reference/events/get_egress_pool/
https://docs.kumomta.com/reference/events/get_egress_source/
Wez or Mike will definitely come with a reply to this thread, until then, you can try implementing it. Hope it helps.

Thank You @yummy-echidna i would definitely try this and let you know if it works .

I am already using a pool which is rotating my proxy ip’s and defining another pool to work for specific ESP like yahoo. also i am not using init.lua for defining my egress pool instead i’m using queues.toml and sources.toml. so could you please suggest according to it.

Sorry, I did not get the chance to research using queues.toml and sources.toml, so i am not familiar with these. But my guess is these are kind of static configurations, I wanted to have a dynamic configurations pulled form a db, so that’s why I use redis to store tenant specific configurations, like pools, sources, allowed sending domains, and i am fetching these values dynamically form the db, cache them and use the values on the fly, when receiving messages.
Better wait for Kumo guys to reply, and take it from there.

Thank you @yummy-echidna for the well thought out answer. That should work fine for a dynamic configuration.

@natural-frog , if you are using the helpers, then you can theoretically make the “tenant” = the receiving domain, but if you plan to do this by mx rollup, that will require some custom Lua. It is doable, but quite complex.

If you want to use the specific receiving domain, you could set tenant meta = receiving domain in the smtp_message_received event, then the queue helper will pick that up and use it.
IE:

    egress_pool = 'pool-2'```
Remember to remove the line `tenant_header = "X-Tenant"` or the tenant meta will be overwritten.