Changing Email Password through API
Hello everyone. Sorry to ask this question again, but I was not allowed to bump an old thread with the same question.
I came across a post from David Neimeyer [url=http://forums.cpanel.net/f42/changing-email-password-using-xml-api-170066.html#post704218](linked here), on changing the password of email accounts.
This is what I came up with:
I would really appreciate some help with these points: 1. Where do I get the include file xmlapi.php? 2. Is $IP the IP address for the host domain? 3. Are my sample values in the proper fields? 4. Is my overall syntax and structure correct? Thanking you all for your kind attention. Any help would be appreciated. :)
//host domain: xyz.com
//cpanel username: xyzusa
//cpanel password: locknkey
//email account: john@abc.com
//new password: js123456
include("xmlapi.php");
$ip = '50.90.180.220'; //should this be the IP address for xyz.com?
$root_pass = 'locknkey';
$account = "xyzusa";
$email_account = "john";
$email_domain = "abc.com";
$xmlapi = new xmlapi($ip);
$xmlapi->set_port (2082);
$xmlapi->password_auth("root", $root_pass);
$args = array('domain'=>$email_domain, 'email'=>$email_account, 'password'=>"js123456"));
$xmlapi->api2_query($account, "Email", "passwdpop", $args);I would really appreciate some help with these points: 1. Where do I get the include file xmlapi.php? 2. Is $IP the IP address for the host domain? 3. Are my sample values in the proper fields? 4. Is my overall syntax and structure correct? Thanking you all for your kind attention. Any help would be appreciated. :)
-
Hi Michael, and thanks for the quick reply. This script is to be run on the host server itself, to try and initiate a password change for one of the email accounts (john@abc.com) hosted on the same server. Sometimes I get no output, and sometimes I get this error: {"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}} Still stuck. :( 0 -
Problem solved! The code is perfect, except for this one oversight on my part: $xmlapi->password_auth("root", $root_pass);
I simply changed the string "root" to the actual cPanel username, which is "xyzusa" in the example. Thank you, David Neimeyer, for this great piece of code. :)0
Please sign in to leave a comment.
Comments
3 comments