Configure EXIM to handle all forwards locally

PeteS

Well-Known Member
Jun 8, 2017
223
48
28
Oregon
cPanel Access Level
Root Administrator
To use AWS SES as SMTP for all non-local mail I have this configured in the PREROUTERS section of the EXIM config file:

send_via_ses:
driver = manualroute
domains = ! +local_domains
transport = ses_smtp
route_list = * email-smtp.us-west-2.amazonaws.com;

I would like to also restrict it from sending forwards set up in accounts on the server to SES. So in the same way that domains = ! +local_domains prevents local mail from routing to SES, I need a conditional statement that would also prevent all forwards from being sent through SES. But I can't find an answer anywhere-probably because I don't know what I'm looking for.

Any help would be appreciated. Thanks.
 

PeteS

Well-Known Member
Jun 8, 2017
223
48
28
Oregon
cPanel Access Level
Root Administrator
Thanks. I have a thread at the EXIM mailing list as well, but so far no response the concept of blocking forwards from a smarthost router.

Hoping for something here - I can't imagine I'm the first to want to handle forwards separately. (I'll post a solution here if I find one elsewhere.)
 
  • Like
Reactions: mamoo108

mamoo108

Registered
Apr 28, 2018
2
2
3
Australia
cPanel Access Level
Root Administrator
Did you end up finding a solid solution for this? I think I have the same setup. It's a shame ses can't forward the emails for us. You can do this manually each time like this:

send_via_ses:
driver = manualroute
domains = ! +local_domains
condition = ${if !eqi{[email protected]$domain}{EMAILADDRESS}}
condition = ${if !eqi{[email protected]$domain}{EMAILADDRESS2}}
transport = ses_smtp
self = send
route_list = * localhost

Where EMAILADDRESS is the email you are forwarding to (your gmail)

Can someone please post here if you find a dynamic way to do this.
 

PeteS

Well-Known Member
Jun 8, 2017
223
48
28
Oregon
cPanel Access Level
Root Administrator
Did you end up finding a solid solution for this? I think I have the same setup. It's a shame ses can't forward the emails for us. ... Can someone please post here if you find a dynamic way to do this.
Thanks for bumping me. I have a solution that appears to work but I got bogged down with other things and didn't test it extensively yet. Here's the link to the relevant part of the EXIM list thread, and what I have so far...

Re: [exim] How to rewrite From: header of offsite forwards only to prevent Amazon SES 554 error

To use AWS SES, you must add domain specific DNS records for ALL domains on server that will send email (Integrating Amazon SES with Exim - Amazon Simple Email Service). The problem is that forwards from off server senders fail (are rejected by AWS SES). Then in the prerouters section I use this, and it appears to do what I want:

PREROUTERS
send_via_ses:
driver = manualroute
domains = ! +local_domains
condition = ${if match_domain{$sender_address_domain}{+local_domains}}
transport = ses_smtp
route_list = * email-smtp.us-west-2.amazonaws.com;

Domain = sends local recipient mail to the local router that follows this one.

Condition = sends mail from a non-local sender (only the case when a non-local sender sends to an alias) to the local router that follows this one.

So only outgoing mail from a local sender to a non-local recipient goes to SES.

I would be interested in how this works for others.
 
Last edited by a moderator:

andryangouw

Member
Jun 26, 2010
14
2
51
Thanks, I was looking for a similar case where smarthost needs to be ignored for valiases or forwards routing.

This line seems to do the trick, but it has a typo. I added it to my routers configuration (I have them in ROUTERSTART section, instead of PREROUTERS).
condition = $if{match_domain {$sender_address_domain}{+local_domains}}
The correct one is
condition = ${if match_domain{$sender_address_domain}{+local_domains}}
 
Last edited:

PeteS

Well-Known Member
Jun 8, 2017
223
48
28
Oregon
cPanel Access Level
Root Administrator
Thanks, I was looking for a similar case where smarthost needs to be ignored for valiases or forwards routing.

This line seems to do the trick, but it has a typo. I added it to my routers configuration (I have them in ROUTERSTART section, instead of PREROUTERS).


The correct one is
Thanks for catching that. Just curious, did it cause an error, just not work, or work even with the incorrect syntax? (I ask because I'm currently not using the AWS SES and can't test, but I thought it was working and I used cut/paste to post here.)

@cPanelMichael Could you edit the code in my post? I can't seem to find the edit function.