I'm using smtproutes to deliver users' email to certain domains through an external SMTP server with example.com:externalsmtp.com
How can I deliver all the emails to my external SMTP except for local virtual domains?
I'm using smtproutes to deliver users' email to certain domains through an external SMTP server with example.com:externalsmtp.com
How can I deliver all the emails to my external SMTP except for local virtual domains?
See the manpage qmail-remote(8)
, Control Files:
smtproutes
Artificial SMTP routes. Each route has the form
domain:relay
, without any extra spaces. Ifdomain
matches host, qmail-remote will connect torelay
, as if host hadrelay
as its only MX. (It will also avoid doing anyCNAME
lookups on recip.) host may include a colon and a port number to use instead of the normal SMTP port, 25:inside.af.mil:firewall.af.mil:26
relay
may be empty; this tells qmail-remote to look upMX
records as usual. smtproutes may include wildcards:.af.mil: :heaven.af.mil
Here any address ending with
.af.mil
(but notaf.mil
itself) is routed by itsMX
records; any other address is artificially routed toheaven.af.mil
.
This doesn't state it directly, but the domain
can be empty, too, which works as a wildcard. Therefore, you can specify a smart host relay, as explained e.g. by Dave Sill in Life with qmail: 3.2.4. Relaying to a smart host.
echo ":smtp.example.com" > /var/qmail/control/smtproutes
So, if you would like to relay everything but example.net
and example.org
through the smart host:
example.net:
example.org:mail.example.org
:smtp.example.com
Here,
example.net
will look for the MX records (empty `relay´),example.org
will go through mail.example.org
, andsmtp.example.com
(empty i.e. wildcard domain
).