If you’re having a problem with your emails being sent or received on a cPanel or any server with exim installed there is a quick and dirty way to test it using a few commands under SSH.
The first thing to do is to check your DNS and MX records to make sure they are all setup correctly. You can use the website http://www.mxtoolbox.com which I have had good results with.
As you can see in the image to the right, smyl.es is only showing one MX record which is set at 0. If you were using multiple mail servers you would normally have something similar to the first server using 10, second server using 20, and so on. Since I’m only using one mail server there is no need for anything higher than 0. If my mail server was hosted on a server different than the one the website is hosted on the hostname should be the hostname of the mail server.
Check DNS and MX records from WHM
Now that we have verified our MX records are correct from another server we need to check inside WHM for cPanel to make sure everything else is correct. If you found any errors above you can correct them through WHM. If you’re using exim separately from cPanel you will need to manually edit these records via SSH or use something like webmin.
Inside WHM go to DNS Functions >> Edit DNS Zone
(for just MX DNS Functions >> Edit MX Entry)
As you can see from the image on the left we have verified that the MX record is as it showed from MX toolbox, this is where you can change it if you had the wrong details above.
Make sure you put a trailing period after the domain, view the image on the left to see what I’m talking about. You should also verify the A record for whatever hostname your using for your MX record is setup correct as well. You may see a CNAME record for the mail subdomain if you’re using the same server for hosting and email.
Also check to make sure cPanel has “Email Routing for..” set at either Automatically Detect Configuration: Local, or Local Mail Exchanger. If the account is set as Automatically Detect Configuration but does not say Local change it to Local Mail Exchanger.
You can also try running a trace from inside cPanel itself. Login to the cPanel account that is having email problems and click on the “Email Trace” icon. This will bring you to a page similar to the image on the right, as you can see the trace shows a success as “virtual_user to local delivery” … you can use this page as another tool in diagnosing the email problem.
Run Exim test via SSH
After checking to make sure DNS and MX settings are setup correctly lets run a test via SSH using Exim and some debug arguments to see if we can find any errors.
exim -d -bt firstname.lastname@example.org
As you can see above we’re running exim with the -d and -bt arguments to test email for email@example.com
You can see the full linux man page on Exim here: http://linux.die.net/man/8/exim
-bt is for running exim in address testing mode for recipient address deliverability.
-d is for debug information…you can filter this information but I prefer to output everything to track down the problem.
Due to the amount of debug information that is output I wont post the entire debug information from this example but I did run the test and changed the Y to an I in the email to simulate an error and this is what I found in the debug output:
exim -d -bt firstname.lastname@example.org --------> fail_remote_domains router >>>>>>>>>>>>>>> Exim pid=4754 terminating with rc=2 >>>>>>>>>>>>>>>>
If you look in the small debug info above we can determine that the problem is in fact a domain problem. Now this will always be different depending on the problem but use this to track it down.
If you’re still having problems you can try some of these commands below:
Add allow_mx_to_ip to Exim configuration
You can add “allow_mx_to_ip = yes” configuration to the /etc/exim.conf file in the off chance that the MX record has an IP set instead of the hostname. This is not recommend by Exim but will allow you to specify an IP in the MX record instead of a hostname. More information: http://www.exim.org/exim-html-3.30/doc/html/spec_11.html#SEC190
The following is specific for cPanel scripts:
Update cPanel User Domains
Update cPanel User Mail Permissions
Guided Mail Troubleshooting
Fix Common Problems and Quotas
Force Exim Update and Default Settings