Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exim4 smarthost selection based on sender

72 views
Skip to first unread message

Gregory Seidman

unread,
Nov 27, 2022, 12:20:05 PM11/27/22
to
I send email from several email addresses. I pay for an email service for
both sending and receiving email, but I pull it down locally (via POP with
fetchmail) and send messages from my Debian server with mutt. All of those
email addresses wind up forwarding to the address with the paid service,
but I neither send nor receive messages directly with that email address.
One of the addresses I send from is hosted by Google, and therefore when I
send from that address through my paid service (which is how exim4 is
configured, using it as a smarthost) recipients usually see a warning about
the message being unverified or suspicious. This is presumably because of
DKIM or something.

What I'd like to do is configure exim4 as it is for most outgoing mail, but
to use GMail as the smarthost when the sender is that one particular email
address. Can someone guide me or give me a hint, please?

--Gregory

Steve McIntyre

unread,
Nov 27, 2022, 1:50:05 PM11/27/22
to
I have exactly this setup, with a couple of different outgoing
smarthosts that need authentication:

I've added a couple of extra stanzas like this in the routers section
*before* the default router (DNS-based in my case, or via default
smarthost maybe for you). Exim will try each of these, looking at the
condition check and falling through if it's not met:

smarthost_example_exploder:
debug_print = "R: smarthost_example_exploder for $local_part@$domain, from $sender_address"
driver = manualroute
domains = ! +local_domains
transport = remote_smtp_smarthost_exploder
route_list = * smtp.gmail.com::587 byname
host_find_failed = defer
headers_add = X-wibble: sender_address $sender_address
condition = ${if exists{CONFDIR/smtp_auth/$sender_address}{${if eq{$sender_address_domain}{example.org}}}}
same_domain_copy_routing = yes

I then add the desired authentication details in
/etc/exim4/smtp_auth/$sender_address for each of the sender addresses.

HTH!

Be aware that doing authenticated smtp to Google and O365 (etc.) is
getting harder and harder as they continue to try to destroy
mail as an open service. :-(

--
Steve McIntyre, Cambridge, UK. st...@einval.com
"We're the technical experts. We were hired so that management could
ignore our recommendations and tell us how to do our jobs." -- Mike Andrews

Marc Auslander

unread,
Nov 27, 2022, 2:41:19 PM11/27/22
to
I used a simple solution:

dc_smarthost='"${if
match{${lc:$header_from:}}{.*xxx.org}{smtp.xxx.net::587}{${if
match{${lc:$header_subject:}}{SSS}{mail.SSS.net}{smtp.googlemail.com::587}}}}"'

Note you can test for any header.

Gregory Seidman

unread,
Nov 27, 2022, 10:20:06 PM11/27/22
to
I *think* I followed that syntax, but I'm not sure because I am not super
familiar with exim4 config. If I'm reading that correctly:

if the from header matches .*xxx.org
then
use smtp.xxx.net
else if the subject matches SSS
then
use mail.SSS.net
else
use smtp.googlemail.com

Is that right? If so, since my use case is all mail goes through the paid
service except what's coming from a single address, is this what I want?

dc_smarthost='"${if match{${lc:$header_from:}}{mye...@somegoogledomain.com}{smtp.googlemail.com::587}{smtp.mypaidservice.com::587}}"'

In addition, is the header match case insensitive and/or can it be?

--Gregory
0 new messages