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. Ifdomainmatches host, qmail-remote will connect torelay, as if host hadrelayas its only MX. (It will also avoid doing anyCNAMElookups 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
relaymay be empty; this tells qmail-remote to look upMXrecords as usual. smtproutes may include wildcards:.af.mil: :heaven.af.milHere any address ending with
.af.mil(but notaf.militself) is routed by itsMXrecords; 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).