March 26, 2020 Contributors


relay_hosts — configure the list of hosts for which Momentum relays mail


relay_hosts = ( "" )


Momentum is a powerful mail delivery system. As an operator, you can expose your system to abuse by allowing unauthorized machines to send e-mail to domains for which the local instance does not provide mail service. Doing so makes your system an "open relay."

When configured to be an outbound e-mail relay, only trusted machines should be allowed to connect and inject messages. This is controlled by the relay_hosts option. This option takes a space-separated list of network blocks in Classless Inter-Domain Routing (CIDR) form. CIDR form consists of an IPv4 address followed by a number between 0 and 32 dictating the number of bits in the network portion of the address, as opposed to the host portion.

For example, all addresses in the loopback space begin with 127. The netmask on a loopback device is, which sets 8 network bits with the remaining 24 bits used for host addresses within the network. Therefore, the CIDR form of the loopback network is For a class C network (256 IP addresses, 254 hosts), the netmask is, which means 24 network bits. The CIDR form of the IP block representing addresses through is Single hosts have netmask with all (32) bits set making a host address have a CIDR form


Hosts specified by this option are not subject to any SMTP authentication that you may have implemented. For more information, see “ESMTP_Listener Authentication”.

The relay_hosts option has no effect on restricting access to an HTTP_Listener.

If your private network ( contains machines that you trust and you wish to also enable relaying from the local host, the following relay_hosts directive would be reasonable:

relay_hosts = ( "" "" )

Use the same syntax for IPv6 addresses:

relay_hosts = ("" "::1" "" "fd82:7796:815b:af9d::")


The relay_hosts option in the global scope follows the same semantics as the rest of the configuration options; if you specify it in both the global scope and in a listener, the listener setting overrides the global setting.

relay_hosts is valid in the global, esmtp_listener, listen, pathway_group, and pathway scopes. While it is valid in the Peer scope, generally speaking, you would not use it in this scope. Use open_relay instead.

See Also