How to setup exim to check the From field
Solution 1:
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.