Create email account using script in Bluehost CPanel

I am trying to create email accounts in cpanel bluehost using PHP script. I tried the XML API for this, but it gives an "Access Denied" error.

Now I am trying to do the same using the following code but with no success. I can log into CPanel, but I cannot sort my email account.

$login = "https://my.bluehost.com/cgi/account/cpanel";
$time=time();
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $login);
curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, "ldomain=$username&lpass=$password&l_redirect=/cgi-bin/cplogin&l_server_time=$time&l_expires_min=0");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
$login_done1 = curl_exec($c);
print_r($login_done1);




   $email= "https://$cpanel:2083/frontend/bluehost/mail/doaddpop.html";
    curl_setopt($c, CURLOPT_URL, $email);s
    curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");
    curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");
    curl_setopt($c, CURLOPT_POST, 1);
    curl_setopt($c, CURLOPT_POSTFIELDS, "email=ddddd&domain=test.org&password=test@1617&password2=test@1617&quota=250&new_email_submit=Create");
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
    $login_done2 = curl_exec($c);
    print_r($login_done2);

      

Any help is appreciated !!

+3


source to share


4 answers


I've been reviewing Bluehost about this issue and the main issue is that Bluehost accounts don't provide su access. super user. Thus, you cannot access the cPanel from any rear doors, not even your own. This is a major pain if the site owner wants to allow users to create email accounts.



0


source


I figured out how to deal with cpanel in BlueHost and create an email account

$account_user

will be the default username to login to Blue Host; It may be the same as $cp_user

, but it definitely doesn't allow it to be root.



 private function createEmail($email, $password) {
    $cp_user = "USERNAME";
    $cp_pwd = "PASSWORD";
    $domain = "yourdomain.com"
    $quota = "500" // This is in Megabytes. 0 Would be unrestricted email box size.
    $account_user = "username"
    $url = "DOMAIN N OR IP :2087 //Your Port";
    $php = "/json-api/cpanel?cpanel_jsonapi_user=".$account_user."&cpanel_jsonapi_version=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=addpop&email=" . $email . "&password=" . $password . "&quota=".$quota."&domain=".$domain;
    $string1 = "https://" . $cp_user . ":" . $cp_pwd . "@" . $url . $php;
    $blueHost = fopen($string1, "r");
    fclose($blueHost);
    return $blueHost;
}

      

Just went through trial and trial and verified the JSON API call when creating an email user on Bluehost.com after login. Hope this helps someone as Blue Host has no support and I was having trouble setting up my email accounts.

+1


source


Another method that has been presented is to enable the user to create the email they want and store it in a database like mysql. Then create and set up a cron job that will periodically check this database for new emails and generate emails in cpanel via the cron job. It's actually quite cumbersome to create email accounts on bluehost. 2 reasons, 1 as I mentioned the -su block. But they are also provided with cpanel resale. So this is really not a full cpanel license. Because cpanel itself has functions for creating email accounts, including creating subdomains. So far, the only ones I've found that offer a real cpanel are Hostgator and Godaddy, I prefer using Bluehost.Just creating another way to create email accounts is to create them in a real file structure. But it can drain quickly with all the encryptions and file structure.

0


source


you can achieve this directly in the chrooted environment (SSH must be enabled via Bluehost / Hostmonster CPANEL). Just specify 127.0.0.1 as $ cpanel and you will never need previous authentication with https: //my.bluehost ... landing page. It works with shared hosts as well as dedicated ones.

Although you need to authenticate via GET:

    curl http://username:password@127.0.0.1:2082/frontend/bluehost/mail/doaddpop.html?blabla

      

Here's a helpful overview that you can translate into your language. Please google for doaddfwd.html dodelpop, dodelfwd etc. Etc. http://beto.euqueroserummacaco.com/blog/criando-contas-de-email-no-cpanel-com-curl/

0


source







All Articles