When I add a new domain via a script, cPanel's "automatic
routing" always thinks it is in Local domains, despite the MX records
I have found that I can use a PHP script to automatically move a new domain
from the localdomains file to the remotedomains file but permissions keep
The code I use is:
exec("sed -i '/^".$domain."$/d' /etc/localdomains");
exec("echo '".$domain."' >> /etc/remotedomains");
The permissions command I use is:
chmod 775 /etc/localdomains
chmod 775 /etc/remotedomains
chgrp nobody /etc/remotedomains
chgrp nobody /etc/localdomains
I'm looking to either:
(Preferable) 1) Determine why cPanel automatic domain routing is set to local when cpanel states that automatic routing is only local if the MX records are pointed to the local machine (they are not, they are always pointed to external servers from the start)
Unfortunately logging into cPanel and selecting the "Remote" option is not an option as staff do not have access to this section.
2) Determine how I can successfully run the above commands to move a domain from localdomains to remotedomains via my PHP script that staff are running. (in a way that does not compromise security of these files)
Thank you so much.
I am also aware of using /scripts/checkalldomainsmxs but this is something that would need to be run on a cron so any time between that cron would have improper mail settings so it is not an acceptable way to do it for us.