Is there a tweak setting to automtically set Automatically Detect Configuration (recommended)??

WebJIVE

Well-Known Member
Sep 30, 2007
122
18
68
I have been fighting this for years but, I'm finally having to ask....

Is there a setting in cPanel that you can set so any new account setup/domain transfer email routing gets set to "Automatically Detect Configuration" - by default?

It's frustrating that when you setup a new account, transfer a domain, etc. (esp. domain transfers) that use an outside email service to have to manually go in to the users cPanel account and change email routing. When you get to this screen, the first option is "Automatically Detect Configuration (recommended)" but the Local Mail Exchanger is selected by default.

Domain transfers are a PITA due to this.
 

Attachments

Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,163
2,410
363
cPanel Access Level
Root Administrator
Hey there! I don't have an option to change the default, but you can change this through WHM >> Create a New Account at account creation time, or with the "mxcheck" option through the creatacct API call.

Would you like me to open a feature request with the team about adding such an option?
 

SimpleTechGuy

Well-Known Member
Mar 22, 2021
59
21
8
United States
cPanel Access Level
Root Administrator
As of March 2016 apparently nothing existed to set the default according to @cPanelMichael. But you could make a hook. Maybe this can be a feature request?

Hello :)

There are no native options to change the default email routing configuration, but you could setup a hook that automatically modifies the value after account creation:

Guide to Standardized Hooks - Software Development Kit - cPanel Documentation
Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation
UAPI Functions - Email::change_mx - Software Development Kit - cPanel Documentation

Thank you.
 

WebJIVE

Well-Known Member
Sep 30, 2007
122
18
68
Thank you and yes, please open that feature request.

We use WHMCS and what kills us is mostly domain transfers bc almost 100% are already using Office365 or Google for email and we have to watch daily emails for completed transfers then jump into the account and set this manually.

In the meantime, I may look into creating a WHMCS hook that sets this for domain transfers and new account creation.

We've been dealing with this pain for years now and it seemed weird to us that it's the recommended default but no way to set that as a default system-wide for account creation, etc.
 

WebJIVE

Well-Known Member
Sep 30, 2007
122
18
68
Pulling my hair out.. Created several WHMCS hooks with no success so I moved to trying the /usr/local/cpanel/scripts/postwwwacct method with the following code and the auto detect still isn't being set on postwwacct execution


Hey there! I don't have an option to change the default, but you can change this through WHM >> Create a New Account at account creation time, or with the "mxcheck" option through the creatacct API call.

Would you like me to open a feature request with the team about adding such an option?
Code:
#!/bin/bash
# Get the account username and password
username=$1
password=$2
domain=$3

# Set the Mail Exchanger type to auto_detect using cPanel UAPI
result=$(curl -s -H "Authorization: Basic $(echo -n "${username}:${password}" | base64)" https://localhost:2083/execute/Email/set_always_accept?domain=${domain})

# Check the result for success or failure
if echo "$result" | grep -q "error"; then
  echo "Error: Failed to set Mail Exchanger type to auto_detect for ${domain}"
else
  echo "Success: Mail Exchanger type set to auto_detect for ${domain}"
fi