Sometimes you may need to automatically update the MX entries for all domains on the server. cPanel has the /usr/local/cpanel/scripts/checkalldomainsmxs script that will attempt to determine if a domains mail is supposed to be handled locally or remotely.
Before running this script a backup of the following files should be made:
After these files are backed up you can run the following command:
This script affects all domains on the server the --yes flag has to be passed to the script.