Question
How can I configure every single domain on my server to have Remote MX routing?
Answer
To start, before following any of the steps below I would suggest creating copies of the following files so the action can be reverted if it was unintentionally done.
/etc/localdomains
/etc/remotedomains
If all of the domains on the server already point to another mx host then the following command will update the routing to set these to be remote.
/usr/local/cpanel/scripts/checkalldomainsmxs --yes
If this doesn't work, then using a bash WHILE loop to loop through all users and domains and using the UAPI command to update these to remote routing will be necessary. I've added a functional While loop below as well as documentation on the uapi command as well as how While loops work.
How to use a while loop in BASH to iterate over all cPanel users on a server
Uapi set_always_accept documentation
awk -F[\ \:] '!/nobody/{print $1 " " $3}' /etc/userdomains | while read DOMAIN USER ; do /usr/bin/uapi --user=${USER} Email set_always_accept domain=${DOMAIN} mxcheck=remote ; done