API to get current mail exchanger routing type

swbrains

Well-Known Member
Sep 13, 2006
293
42
178
I am looking for an API function to retrieve the current mail exchanger routing type (local/remote/auto). I can successfully set it using the set_always_accept API call, but I can't find a way to retrieve the current setting.

I found the function get_user_information , and while it's returned data description includes a hash called "mxcheck" which should contain the current mail routing type for each domain, "mxcheck" is not included anywhere in the main hash that is returned. I dump the main hash returned from the call using Perl's Data::Dumper, and could not locate any property called "mxcheck", or any property that seemed to contain the local/remote/auto setting that I'm looking for.

Is there some other way to determine the current setting for the mail exchanger routing type for a domain?

Thanks!
 

ServerHealers

Well-Known Member
Sep 21, 2015
92
51
68
India
cPanel Access Level
Root Administrator
The API is currently not returning mxcheck parameter, so it might be removed from that API I think. Another option is to retrieve it using below command:

grep -l "^DOMAIN$" /etc/{localdomains,remotedomains}
Replace DOMAIN with your actual domain name.

If this returns /etc/localdomains - then the domain is set to Local routing
If this returns /etc/remotedomains - then the domain is set to Remote routing.
 

swbrains

Well-Known Member
Sep 13, 2006
293
42
178
I checked in the /etc directory but I don't have a localdomains or a remotedomains file or folder, even after I set the account to "local" or "remote" exchanger type.
 

swbrains

Well-Known Member
Sep 13, 2006
293
42
178
Ok, it looks like you're referring to the root's /etc folder, whereas I was looking at the account's /etc folder. Unfortunately, I need to determine the exchanger type from a script running under a user's account, so the script won't have access to the root's /etc folder.
 

ServerHealers

Well-Known Member
Sep 21, 2015
92
51
68
India
cPanel Access Level
Root Administrator
Unfortunately, I don't think there is a way to determine this as a normal user at this stage. You would need root level access to the server to crawl up through those files I mentioned earlier.
 

ServerHealers

Well-Known Member
Sep 21, 2015
92
51
68
India
cPanel Access Level
Root Administrator
Great! If you could share the link to your feature request in this thread then it would be helpful for others to upvote on it easily. :)