D
Deleted member 872007
Guest
I'm using the below PHP code (using the xml API interface) to change passwords for email accounts:
function change_email_password($xmlapi, $email, $password) {
// Note that $email is just the username part of the email
$req = array("email" => $email, "password" => $password, "domain" => EMAIL_DOMAIN);
$response = $xmlapi->api1_query(CPANEL_USERNAME, "Email", "passwdpop", $req);
$decoded = json_decode($response, true);
return $decoded;
return get_cpanel_reason($decoded, "Failed to change email password for an unknown reason.");
}
Calling the code by using:
die(var_dump(change_email_password(get_cpanel_xmlapi(), 'somemail','3e6agh3tzdafg3wartdwa')));
Returns:
array(8) { ["apiversion"]=> string(1) "1" ["type"]=> string(5) "event" ["module"]=> string(5) "Email" ["func"]=> string(9) "passwdpop" ["source"]=> string(6) "module" ["data"]=> array(1) { ["result"]=> string(233) "
The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher. " } ["event"]=> array(2) { ["result"]=> int(0) ["reason"]=> string(224) "Email::passwdpop() failed: The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher." } ["error"]=> string(224) "Email::passwdpop() failed: The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher." }
Any idea where things go wrong? The strength rating of a password is 0 all the time.
function change_email_password($xmlapi, $email, $password) {
// Note that $email is just the username part of the email
$req = array("email" => $email, "password" => $password, "domain" => EMAIL_DOMAIN);
$response = $xmlapi->api1_query(CPANEL_USERNAME, "Email", "passwdpop", $req);
$decoded = json_decode($response, true);
return $decoded;
return get_cpanel_reason($decoded, "Failed to change email password for an unknown reason.");
}
Calling the code by using:
die(var_dump(change_email_password(get_cpanel_xmlapi(), 'somemail','3e6agh3tzdafg3wartdwa')));
Returns:
array(8) { ["apiversion"]=> string(1) "1" ["type"]=> string(5) "event" ["module"]=> string(5) "Email" ["func"]=> string(9) "passwdpop" ["source"]=> string(6) "module" ["data"]=> array(1) { ["result"]=> string(233) "
The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher. " } ["event"]=> array(2) { ["result"]=> int(0) ["reason"]=> string(224) "Email::passwdpop() failed: The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher." } ["error"]=> string(224) "Email::passwdpop() failed: The password that you entered has a strength rating of “0”. You cannot use it because it is too weak and too easy to guess. Please enter a password with a strength rating of “65” or higher." }
Any idea where things go wrong? The strength rating of a password is 0 all the time.