1

I have been plagued with a situation which has yielded no elegant solutions, from any support avenues. I have a domain, the email accounts on this domain are hosted on both Office365 and a cPanel VPS. The VPS is set up as a "smarthost". My MX record points to Office 365, if no matching account is found, the email will be directed to my VPS. If no matching account is found on the VPS, the email message delivery will fail. This all works as expected.

My issue arises if I send an email from the VPS server to the domain which is shared between Office 365 and the VPS, my VPS assumes this is a local email account and delivery fails.

This has been my stop gap solution, added to my Exim configuration in the prerouters section:

office365exchangeForward:
  driver = manualroute
  condition = ${lookup{$local_part@$domain}lsearch{/home/ben/etc/exim_office365hostedaddresses} {yes}{no}}
  transport = remote_smtp
  route_list = * bensdomain-com.mail.protection.outlook.com

This subsection checks the recipient address against manually maintained file. If a match exists, the message is forwarded off the VPS back to Office 365 for delivery. This works effectively, but whenever a new alias/group/address is added on the Office 365 side, this file must be manually updated.

Can anyone offer any insight as to how I can accomplish a solution to this split hosting email delivery, without the manual maintenance step?

benjam1nk
  • 11
  • 1
  • **Can anyone offer any insight as to how I can accomplish a solution to this split hosting email delivery, without the manual maintenance step?** - Yes. Stop doing it. – joeqwerty Nov 05 '20 at 00:56
  • Can you automate the extract of the O365 addresses into that file? – Andrew Schulman Nov 05 '20 at 15:31
  • @AndrewSchulman I created a powershell utility to extract and upload addresses to designated file, but this needs to be done every time a change has been made in O365. Just seems like there has to be an easier solution. – benjam1nk Nov 05 '20 at 19:11

1 Answers1

0

If the user list is available as some kind of service from O365, you might be able to use one of the other exim lookup types, such as json or ldap, instead of lsearch.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47