How To Split Email
This post consists of Exim’s setting on cPanel server. For Split Delivery setting on Google Apps, please refer to : https://support.google.com/a/answer/173534?hl=en
I have few email accounts on my cPanel VPS server and currently migrating/switching to Google Apps. But, i don’t want all email accounts to be moved to Google Apps. Let’s just say, 70% of the email account will be moved to Google Apps and another 30% will not be migrated to Google Apps.
Google has a feature called Mail Routing. It can be used to delivery email accounts -that are not in Google Apps- to another mail server. But the problem is, cPanel only knows 3 type of mail routing : Local, Backup and Remote Mail Exchanger
If i updated mail exchanger setting to ‘Local Mail Exchanger’, then emails from Google Apps account (from the same domain name, obviously) can be delivered to email accounts on cPanel server, but not the other way around. But, if i changed the setting to ‘Remote Mail Exchanger’, then emails from Google Apps account will be failed.
Since i have the list of email accounts that are in Google Apps, i tried to update Exim router to reroute email based on email address. Here’s what i’ve done so far:
Update MX record to Google Apps MX records and use ‘Local Mail Exchanger’
Create a file that contains all email addresses that’ve been migrated to Google Apps
touch /etc/gapps_accounts
chown root:mail /etc/gapps_accounts
chmod 660 /etc/gapps_accounts
Add email addresses to /etc/gapps_accounts.
Update Exim routers
Add the lines below in PREROUTERS section at Exim Configuration Manager menu ( WHM >> Exim Configuration Manager >> Advanced Editor ) :
gapps_route:
condition = ${lookup{$sender_address}lsearch{/etc/gapps_accounts} {no} {yes}}
condition = ${lookup{[email protected]$domain}lsearch{/etc/gapps_accounts} {yes} {no}}
driver = manualroute
transport = remote_smtp
route_list = * aspmx.l.google.com
Send the incoming email to old email account (on VPS) to blackhole by using forwarder