How to use a remote MX mail server for mails in CPanel
I hit an issue recently with routing of mail. Whenever mail was sent from a php script on my server it would not send the mail out. The reason for this is because the same server has domain names and email accounts configured locally. So the system just routed the mails to the local server.
This wouldn’t be an issue if I was using this server as my mail host but I’m not. I use a remote MX mail server that should handle these emails. So I had a look around on google but couldn’t find a solution. There wasn’t one that suited my needs.
After some digging around in Cpanel I came up with a quick and easy solution that I hope will help anyone else in this situation. The steps are as follows:
- First logon to Cpanel and navigate to Email – Email Routing.
- Select the local domain you would like to route emails for. This will open a window and will default to Automatically Detect Configuration: Local. Now select the tick box next to Remote Mail Exchanger and click Change.
- Now click on Zone Editor – There is a link above
- Under Record change Destination field from your domain to mail.yourdomainname.com
- Look for mail.yourdomainname.com under name on the left hand side. Now change the type from CNAME to A record and on the right under Record you need to add the ip address of your remote MX mail server that will handle your mail delivery.
This should resolve the issue. Now any emails sent from the server locally by PHP scripts will be forced to send these out via your remote MX mail server.