How to setup exim to check the From field

exim

We setup exim to use Amazon SES to route all your emails, but we found out that if we use an email forwader created by cPanel, Amazon doesn't properly route those emails because it's coming from a From field that is unknown by Amazon.

Therefore, how can we set up exim to bypass the Amazon route if the From field is from a non-local domain?

The error I'm getting is:

2014-06-11 21:50:21 1Wuu9k-00073D-Gn ** XXX R=send_via_ses T=ses_smtp: SMTP error from remote mail server after end of data: host ses-smtp-us-west-2-prod-14896
026.us-west-2.elb.amazonaws.com [54.213.254.236]: 554 Message rejected: Email address is not verified.

Best Answer

After a few exploratory questions, we've concluded that the issue is you need to detect when a message sender is not local and route it differently. So first, I would detect non-local senders by adding to the RCPT acl:

warn  condition = ${if forany{+local_domains}{eq{$item}{$sender_address_domain}}}
      set acl_m_use_ses=1

The forany loops through all domains in the +local_domains list and compares each one to $sender_address_domain. The variable only gets set if the sender domain is in that list. Then in your router, you add the requirement that the variable must be set to 1:

condition = ${if eq{$acl_m_use_ses}{1} {yes}{no}}

Then the outbound message will skip that router if the MAIL FROM envelope sender does not have a domain that is recognized by exim as a local domain. For the emails which skip this router, you must have a subsequent router that will either try to send the email out directly using SMTP or out through a different smarthost that doesn't require the domain to match.

Related Topic