Listener specific routing

Your question

Does Stalwart v0.16 allow a listener specific routing e.g. the LMTP listener always uses ‘local’ delivery and if yes how do I configure that in either GUI or with stalwart-cli?

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Yes, v0.16 can do this. The catch is that listener and local_port are session-level variables and aren’t available in the outbound routing context, so you can’t branch on them directly there. The message-level equivalent is received_via_port, the local port the message came in on, and that one is allowed in the route expression. So for “LMTP always delivers locally” you’d set the route on your outbound strategy to:

if received_via_port == 24 then ‘local’ else ‘mx’

‘local’ is a built-in route that does local mailbox delivery, so no route object is needed for it. In the admin UI the route expression is under Settings > MTA > Outbound > Strategy; with the CLI it’s the MtaOutboundStrategy singleton (stalwart-cli update MtaOutboundStrategy …). The variables available in that expression are listed at MtaQueueRcptVariable | Stalwart and the strategy object at Strategies | Stalwart.