Route Email via External SMTP Relay

Hi I want to route bulk emails sent by some internal IP’s and sender addresses via external SMTP Relay (maileroo.com).
In addition to that I want everyone else to use default path with direct delivery. If any one has any valid confiugration please provide as I am struggling to do it rightly from quite some time. Thanks
root@smtpblk:/ kumod -V
kumod 2025.05.06-b29689af

Attached is my init.lua.
message.txt (7 KB)

Not saure about SMTP, but this is what I found: kumomta/docs/userguide/policy/http.md at 64ac5ad43b3d711262f01f7ca241d7227c34f25f · KumoCorp/kumomta · GitHub

You can easily adapt this script to connect to the Maileroo API

Oh, and this is for SMTP Relay:

Setup a custom mx_list poiinting to smtp.maileroo.com:587.

And then setup SMTP Auth:

I am using below confiugration however email is always routed from default path and does not matches. – ==============================================================
– ROUTING DECISION HELPER FUNCTION
– ==============================================================
local function should_use_maileroo(msg)
local mail_from = “”
local sender_obj = msg:mail_from()
if sender_obj and sender_obj.address then
mail_from = sender_obj.address:lower()
end

– Get the source IP from message reception meta
local source_ip = “unknown”
local peer = msg:meta(“peer_address”)
if peer and peer.addr then
source_ip = peer.addr
end

local use_maileroo = (mail_from == “billing@xyz.com” or source_ip == “172.29.100.82”)

if use_maileroo then
kumo.log_info(string.format(“MAILEROO ROUTING: MAIL FROM=%s, SOURCE IP=%s”, mail_from, source_ip))
end

return use_maileroo
end

– ==============================================================
– QUEUE CONFIGURATION - SIMPLIFIED
– ==============================================================
kumo.on(“get_queue_config”, function(domain, source, site, msg)
if msg:get_meta(“route_via_maileroo”) == “yes” then
kumo.log_info(string.format(“MAILEROO: Creating queue config for domain=%s”, domain))

return kumo.make_queue_config {
  name = string.format("maileroo~%s", domain),
  protocol = {
    smtp = {
      relay_host = "smtp.maileroo.com",
      relay_port = 587,
      ehlo_domain = "xyz.com",
      smtp_auth = {
        type = "plain",
        username = "billing@xyz.com",
        password = "Test_Password",
      },
      enable_tls = "Required",
      connect_timeout = "30s",
      idle_timeout = "60s",
    },
  },
  max_concurrency = 10,
  max_age = "24h",
  retry_interval = "1h",
  max_retry_interval = "4h",
  max_message_rate = "500/1m",
}

end

side question, can you specify multiple SMTP relayes and do a roundrabin dispatch between them to load balance?

Not really. My egress source, pool and path dont match anything and just send the email to default route.

Even though i have defined egress pool and source, Still it defaults to unpecified which is default. Anyone can help?

We are all just amazed your GenAI config loaded at all. There’s so much wrong with it that helping you would mean rewriting it on your behalf. Read the docs and follow them, then get back to us.

Check attached bare minimum config and confirm if KumoMTA cannot directly relay to an external SMTP requiring authentication via make_egress_source. My configuration is now bare minimum however I am still struggling what I am doing wrong. Please help. Thanks
message.txt (2.56 KB)

smtp_auth = {
        type = 'plain',
        username = 'billing@xyz.com',
        password = 'XYZ_Password',
      },

Pls link where in the docs you got that syntax.

I dont get its reference in https://docs.kumomta.com/reference/kumo/make_egress_source so assume that I should be able to target external SMTP with authentication via make egress Source and Pool. I hope its doable. Thanks

Where did you get that syntax?

I included it but cant find its reference. I know its a bad practice to include the username password in plain text but https://docs.kumomta.com/reference/kumo/make_queue_config/protocol defines no method to call external SMTP via authentication.

Well that is pretty clearly hallucinated LLM code.