0

I want to create email account in cpanel by php scripts. I am using this following code:

<?php
include("xmlapi.php");        //XMLAPI cpanel client class

$ip = "XXX.XX.XXX.XXX";            // should be server IP address or 127.0.0.1 if local server
$account = "XXXXX";        // cpanel user account name
$passwd ="L97$41lw";          // cpanel user password
$port =2083;                  // cpanel secure authentication port unsecure port# 2082
$email_domain ="mywebsite.com";
$email_user ="john";
$email_pass ="johnspassword";
$email_quota = 0;             // 0 is no quota, or set a number in mb

$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);     //set port number.
$xmlapi->password_auth($account, $passwd);
$xmlapi->set_debug(0);        //output to error file  set to 1 to see error_log.

$call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);

$result = $xmlapi->api2_query($account, "Email", "addpop", $call );
echo '123';
echo   $result;
?>

My xml.api link is http://mywebsite.com/xmlapi.php. When i am executing the code no error is showing also not getting any value as $result

Kunal Roy
  • 1
  • 1
  • 5
  • 1
    Would you mind to `$xmlapi->set_debug(1);` and show the result of execution? – Aleksei Matiushkin Nov 06 '14 at 16:26
  • If you want to skip XML and use straight PHP, this works: http://www.zubrag.com/scripts/cpanel-create-email-account.php – Len_D Nov 06 '14 at 16:27
  • Unquoted keys in the `$call` array could be part of the problem. – Don't Panic Nov 06 '14 at 16:35
  • @Len_D I tried that way but it's returning error - Warning: fopen() [function.fopen]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/vcrmsol/public_html/cpemail.php on line 78 Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode. Also missing this doaddpop.html – Kunal Roy Nov 10 '14 at 17:59
  • Read this: http://php.net/manual/en/filesystem.configuration.php and this: http://stackoverflow.com/questions/1982197/how-to-turn-off-php-safe-mode-off-for-a-particular-directory-in-a-shared-hosting – Len_D Nov 10 '14 at 18:13
  • Thanks to all of you. I made it, I used JSON. I found issue with XML my server was not supporting that properly (maybe there's some issues but I tried it with json and it's done). – Kunal Roy Nov 28 '14 at 19:30

0 Answers0