Is there a way to force mail routing to "auto" on all domains?

4u123

Well-Known Member
PartnerNOC
Jan 2, 2006
948
29
178
I've been using a plugin with an external MTA that sets mail routing to "local" when using certain MX records. I would like to reset all domains on the server to "auto" routing. Is this possible?

Is there also any process that can be run that will check each domain to determine the routing and set the /etc/localdomains or /etc/remotedomains files accordingly?

Finally, if an MX record has an IP that matches an IP in the "Remote Service IP's" > "Remote Mail Server IP's" list, with "auto"set on the routing, will this consider the MX record to be local rather than remote?

Thank you.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Hello,

You'd have to create a loop for it but the following UAPI function would allow you to set the mail exchanger type for all zones to auto:

Code:
uapi --user=$USER Email set_always_accept domain=$DOMAIN.TLD mxcheck=auto
details on it can be found here: UAPI Functions - Email::set_always_accept - Developer Documentation - cPanel Documentation


Finally, if an MX record has an IP that matches an IP in the "Remote Service IP's" > "Remote Mail Server IP's" list, with "auto"set on the routing, will this consider the MX record to be local rather than remote?
The documentation on this can be found here:

Based on what it says:
This interface allows you to specify remote mail server and nameserver IP addresses that the system will then consider as local addresses.
The IP's listed here would be considered local.
 

4u123

Well-Known Member
PartnerNOC
Jan 2, 2006
948
29
178
Great stuff, thanks.

Does this UAPI function simply set the routing to auto - or does it also process the domain and set it into localdomains / remotedomains accordingly?

When you say I'd need to create a loop for it, would /etc/userdomains be good as as a reference point?
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Great stuff, thanks.

Does this UAPI function simply set the routing to auto - or does it also process the domain and set it into localdomains / remotedomains accordingly?

When you say I'd need to create a loop for it, would /etc/userdomains be good as as a reference point?
Any time you set the routing it adds the domain to the respective file.

For looping through the users - userdomains would be good to get their domains from yes but the list domains UAPI function might be better: UAPI Functions - DomainInfo::list_domains - Developer Documentation - cPanel Documentation.

An example of loops for users can be found in the following as well List of all Emails on a Domain?