1

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?

Adam Zalcman
  • 780
  • 5
  • 19
Rossino
  • 11
  • 1

1 Answers1

0

See the manpage qmail-remote(8), Control Files:

smtproutes

Artificial SMTP routes. Each route has the form domain:relay, without any extra spaces. If domain matches host, qmail-remote will connect to relay, as if host had relay as its only MX. (It will also avoid doing any CNAME 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 up MX records as usual. smtproutes may include wildcards:

.af.mil:
:heaven.af.mil

Here any address ending with .af.mil (but not af.mil itself) is routed by its MX records; any other address is artificially routed to heaven.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,

  • mail to example.net will look for the MX records (empty `relay´),
  • mail to example.org will go through mail.example.org, and
  • everything else will go through the smart host smtp.example.com (empty i.e. wildcard domain).
Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122