Skip to main content


ec_set_routing_gateway — dynamically change the gateway based on recipient


ec_set_routing_gateway { address }


This action sets the gateway for the message in much the same way as the gateway configuration option; the message will be queued to the domain specified by the gateway. A gateway set with this action will override a possible Gateway configuration setting that would otherwise be applicable to the message. See also routes for domain-wide routing. The headers and the body of the message will not be changed.

The required address parameter can be either a dotted literal IP address, a hostname that resolves to an A record, or a domain name which resolves to one or more MX records.

Sieve scripts using ec_set_routing_gateway should be called in the each_rcpt_phase only.

if envelope :domain :is "to" "" {
  ec_set_routing_gateway "";


In order to prevent I/O on the scheduler, when using ec_set_routing_gateway, the keep_message_dicts_in_memory option should be set to true.


The sievelib module must be loaded explicitly in your configuration for correct operation of ec_set_routing_gateway.

See Also

Was this page helpful?