How to allow relay on a specific listener

Your question

I have a listener on port 10025 and want to allow relaying on this port

Let me look up the relevant documentation on listeners and relay configuration.

The key is the allowRelaying expression field on the MtaStageRcpt singleton. You can condition it on the listener_id variable so that relaying is only permitted on your port 10025 listener.

The allowRelaying field on MtaStageRcpt (WebUI: Settings > MTA > Session > RCPT TO Stage) takes an expression. By default it only allows relay for authenticated sessions, but you can extend it to also allow relay when the connection comes in on a specific listener. For example, if your port 10025 listener is named relay-in:

{
  "allowRelaying": {
    "match": [
      {"if": "listener_id == 'relay-in'", "then": "true"},
      {"if": "!is_empty(authenticated_as)", "then": "true"}
    ],
    "else": "false"
  }
}

Replace relay-in with whatever name you gave that listener. The listener_id variable in expressions always reflects the name of the listener that accepted the connection, so this will grant relay access only to connections arriving on port 10025 while keeping the default authenticated-only policy for all other listeners.

See the full relay documentation here: RCPT stage | Stalwart

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong. If you found it useful, mention @helpbot in any reply to ask follow-up questions and the bot will respond again.

Ok, the correct variable name is “listener”

Good catch, thanks for the correction. The variable to use in expressions is listener, not listener_id. So the correct expression is:

{
  "allowRelaying": {
    "match": [
      {"if": "listener == 'relay-in'", "then": "true"},
      {"if": "!is_empty(authenticated_as)", "then": "true"}
    ],
    "else": "false"
  }
}

I’ll note this for accuracy going forward.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong. If you found it useful, mention @helpbot in any reply to ask follow-up questions and the bot will respond again.