How to deliver to a custom mx and port

I’m trying to debug and test some mail and want to route messages going to @mail.local to Mailhog running on port 1025 on the local machine.

In my init.lua I have:

kumo.on('get_queue_config', function(domain, tenant, campaign, routing_domain)
  if domain == 'mail.local' then
    -- Relay via some other internal infrastructure.
    -- Enclose IP (or IPv6) addresses in `[]`.
    -- Otherwise the name will be resolved for A and AAAA records
    return kumo.make_queue_config {
     protocol = {
       smtp = {
         mx_list = {
           'mail.local',
           { name = 'mail.local', addr = '127.0.0.1:1025' },
         },
       },
     },
   }
  end

  -- Otherwise, just use the defaults
  return kumo.make_queue_config {}
end)

Email sent to test@mail.local just disappears.

Also, can the protocol with smtp options not be set inside the queues.toml file? When I try to do so, I get an error that mx_list is an unsupported property.

Any help on how to make the custom delivery work or what I’m doing wrong would be appreciated.

Thanks.

It also looks like kcli trace-smtp-client and kcli trace-smtp-server do not work with https endpoints

routing_domain

“…can the protocol with smtp options not be set inside the queues.toml file? “
No. Queues and shaping and sources are all separate things that work together in combination. A queue is the storing messages before egress. The shaping adds throttles and special egress parameters (like outbound smtp port) and the source defines what ip to use and what name to present it with.

You could set an IPTABLES routing rule.
Or you could use a routing_domain as already recommended. In the shaping for that routing domain, you can set the prefered port.

Hello, have you been able to solve this issue? I am facing something similar, while trying to route the message to mailhog localhost:1025 - messages just sit there, not in any queue, not picked up.

Basically, Kumo stops at:

[40545931-2e82-4ccd-bd94-3e9d598e97a8]       === conn_meta egress_pool="dev_pool"
[40545931-2e82-4ccd-bd94-3e9d598e97a8]       === conn_meta egress_source="dev1"
[40545931-2e82-4ccd-bd94-3e9d598e97a8]       === conn_meta id="40545931-2e82-4ccd-bd94-3e9d598e97a8"
[40545931-2e82-4ccd-bd94-3e9d598e97a8]       === conn_meta mx_plan={"Addresses":[{"addr":"127.0.0.1","name":"localhost"}]}
[40545931-2e82-4ccd-bd94-3e9d598e97a8]       === conn_meta ready_queue_name="dev1->mx_list:127.0.0.1@smtp_client"``` 

So I know my routing is badly configured, but not sure where.

Well, the name of the functions are “smtp-trace-*” so they were not designed for http.

You need to set the outbound smtp port in shaping directives. You have not included any configs so it is really impossible to provide specific help beyond that.