Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Email Password Change wihout login in cpanel

  1. #1
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Exclamation Email Password Change wihout login in cpanel

    Friends, I would like a permanent solution to a script to change password without email access cpanel.

    I tried the cpanel api but I could not ...

    Could you help me?

    I need a page where the User enter the email address and new password, after which the password is changed ...

    Please help me ... Thank you!

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    2

    Default

    I was working tirelessly over this issue for about an hour...
    My forum was set up so that if you donated you got an email and password as you requested - but it was through me... My email users wanted to change there email passwords. Since I was using my own email client script, I didn't want to reveal my hosters crappy webmail function from cpanel, thus I had to make a script to do it without logging into the webmail of cpanel. This is what I got.

    (I searched google for this problem and never found a straight answer, so I had to figure it out myself. This might help other googler's in the future. ;P)

    Code:
    <html>
    <body>
    <form name="input" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
    Email:<br />
    <input type="text" name="email" />@example.com<br />
    Password:<br />
    <input type="password" name="pass" /><br />
    New Password:<br />
    <input type="password" name="newpass" /><br />
    <input type="password" name="newpass2" /><br />
    <input type="submit" value="Submit" />
    </form>
    <br />
    <?php
    
    $username = $_POST['email'];
    $password = $_POST['pass'];
    $cpaneldomain = 'example.com';
    $email = $_POST['email'];
    $emaildomain = 'example.com';
    $newpass = $_POST['newpass'];
    
    if($_POST['newpass']=="")
    {
    echo "";
    }
    else if($_POST['newpass']==$_POST['newpass2'])
    {
    echo "New password submitted.";
    @file("http://$username@$emaildomain:$password@$cpaneldomain:2095/webmail/x/mail/dopasswdpop.html?redirectdomain=&email=$email&domain=$emaildomain&password=$newpass");
    }
    else
    {
    echo "The two new password fields must be the same.";
    }
    ?>
    </body>
    </html>
    Hope this helps some people with understanding the cpanel api and so forth.

    Thanks.

  3. #3
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default not working for me

    you tested in cpanel 11?

    the message "New password submitted." has displayed.. but the passwords not change...

  4. #4
    Registered Member MattDees's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    Fumagally, well this is possible (via a few methods).
    The params for passwdpop are as follows:

    my ( $email, $passwd, $quota, $domain, $quiet ) = @_;

    So, if you wanted to change a user's password (for testemail@cptest.com) via the API you would do the following:

    Code:
    /xml-api/cpanel?
    cpanel_xmlapi_module=Email&
    cpanel_xmlapi_func=passwdpop&
    cpanel_xmlapi_apiversion=1&
    arg-0=testemail&
    arg-1=testing321&
    arg-3=cptest.com
    or via the xml-api class:


    Code:
    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port(2096);
    $xmlapi->password_auth("testemail@cptest.com", $oldpass);
    $xmlapi->api1_query($account, "Email", "passwdpop", array("testemail", $newpass, 0, "cptest.com"));

    There are other ways to do this.. but this is the only one that has a guarantee of always working. I should also note that in the api1_query I pass a quota of zero. If this is called via the webmail interface, this will not change the quota (this is enforced in the email module).
    Matt Dees

  5. #5
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default help...

    Quote Originally Posted by cPanelMatt View Post
    Fumagally, well this is possible (via a few methods).
    The params for passwdpop are as follows:

    my ( $email, $passwd, $quota, $domain, $quiet ) = @_;

    So, if you wanted to change a user's password (for testemail@cptest.com) via the API you would do the following:

    Code:
    /xml-api/cpanel?
    cpanel_xmlapi_module=Email&
    cpanel_xmlapi_func=passwdpop&
    cpanel_xmlapi_apiversion=1&
    arg-0=testemail&
    arg-1=testing321&
    arg-3=cptest.com
    or via the xml-api class:


    Code:
    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port(2096);
    $xmlapi->password_auth("testemail@cptest.com", $oldpass);
    $xmlapi->api1_query($account, "Email", "passwdpop", array("testemail", $newpass, 0, "cptest.com"));

    There are other ways to do this.. but this is the only one that has a guarantee of always working. I should also note that in the api1_query I pass a quota of zero. If this is called via the webmail interface, this will not change the quota (this is enforced in the email module).

    Yeap!! Understand what you said ... could provide a complete script running .. I think you need only 2 files to make it happen ... Am I right? If you can help thank you very much!

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    2

    Default

    There is nothing wrong with it - maybe I should explain a bit further...

    For this:
    <input type="text" name="email" />@example.com<br />

    @example.com should be your email domain.

    For these:
    $cpaneldomain = 'example.com';
    $emaildomain = 'example.com';
    Change to cpanel domain and email domain..

    It should be filled out like:

    Username:
    [email]@example.com
    Password:
    [emailpassword]
    New Pass:
    [newpassword]
    [repeatpassword]

    Then submit. As long as the the info is submitted correctly, it should work fine, with no problems.

    Almost forgot..

    @file("http://$username@$emaildomain:$password@$cpaneldomain:2095/webmail/x/mail/dopasswdpop.html?redirectdomain=&email=$email&domain=$emaildomain&password=$newpass");

    Your /webmail port should be 2095 if not change it above.. and your skin should be "x" as stated above in ^ /webmail/"x"/mail/ ^ if this is not the case change it... just login into webmail the normal way to firgure out your skin - it will be where the x is.

    Thanks.

  7. #7
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default Thanks

    WOOOWWWW... agora sim consegui... tive que remover o @ no @file

    e alterar a linha do tema para x3...

    Very thanks SeanStar...

    cPanelMatt.. do you have a complete script with api?

  8. #8
    Registered Member MattDees's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    What I gave you, pretty much IS the complete script, see:

    http://forums.cpanel.net/f42/xml-api...-a-136449.html
    Matt Dees

  9. #9
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default how to

    Well, let's split ... your first example works, the second I could not ..

    So the url will look like this:

    http://DOMAIN:2095/xml-api/cpanel?cp...D&arg-3=DOMAIN

    How do in PHP to log into webmail and perform this action, and then give me a success message or error?

  10. #10
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default try

    Quote Originally Posted by cPanelMatt View Post
    What I gave you, pretty much IS the complete script, see:

    http://forums.cpanel.net/f42/xml-api...-a-136449.html
    cPanelMatt >>> I tried so:

    PHP Code:
    <?
    include("xmlapi.php");

    $ip = "XXXXX";


    $email_completo = "teste@uaiinformatica.com.br";
    $oldpass = "XXXX";
    $newpass = "XXXX";


    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port(2096);
    $xmlapi->password_auth($email_completo, $oldpass);
    print $xmlapi->api1_query($account, "Email", "passwdpop", array("teste", $newpass, 0, "uaiinformatica.com.br"));
    ?>
    BUT... NOT SUCESSS... ANYONE MESSAGE HAS DISPLAYED...

  11. #11
    Registered Member cPanel Partner NOC Badge cyon's Avatar
    Join Date
    Jan 2003
    Posts
    325

    Default

    Try to replace $account with your emailadress. The reason you don't see any printed character is, because the $xmlapi->api1_query returns a SimpleXML-Object -> PHP: SimpleXML - Manual
    You can do
    PHP Code:
    var_dump($xmlapi->api1_query($account"Email""passwdpop", array("teste"$newpass0"uaiinformatica.com.br"))); 
    If you do this, you'll see, that the 'result' Value is empty. If you try to change the password by using the direct url mentioned by cPanelMatt you'll also get an XML response, where the 'result' tag is empty.
    For that, if you get a empty result and no error, your password is changed correctly.

  12. #12
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default sucess!

    Quote Originally Posted by cyon View Post
    try to replace $account with your emailadress. The reason you don't see any printed character is, because the $xmlapi->api1_query returns a simplexml-object -> php: Simplexml - manual
    you can do
    PHP Code:
    var_dump($xmlapi->api1_query($account"email""passwdpop", array("teste"$newpass0"uaiinformatica.com.br"))); 
    if you do this, you'll see, that the 'result' value is empty. If you try to change the password by using the direct url mentioned by cpanelmatt you'll also get an xml response, where the 'result' tag is empty.
    For that, if you get a empty result and no error, your password is changed correctly.
    view post bellow ::::
    Last edited by fumagally; 12-04-2009 at 07:40 AM.

  13. #13
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default idea

    HOW TO DISPLAY A MESSAGE IN THE PAGE??

    I have an idea .... can do as follows:

    PHP Code:
    <?
    include("xmlapi.php");

    $ip = "***************";


    $email_user = "teste@uaiinformatica.com.br";
    $oldpass = "**********";
    $newpass = "**********";


    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port(2096);
    $xmlapi->password_auth($email_user, $oldpass);

    if (***HOW TO GET password_auth SUCESS????****) {
    $xmlapi->api1_query($email_user, "Email", "passwdpop", array("teste", $newpass, 0, "uaiinformatica.com.br"));
    print "Password changed!!!";
    }
    else {
    print "OLD PASSWORD INCORRECT!";
    }

    ?>
    HOW TO GET password_auth SUCESS????
    Last edited by fumagally; 12-04-2009 at 07:46 AM.

  14. #14
    Registered Member
    Join Date
    Nov 2009
    Posts
    13

    Default ??

    anyone.... help please...

  15. #15
    Registered Member cPanel Partner NOC Badge cyon's Avatar
    Join Date
    Jan 2003
    Posts
    325

    Default

    Take a look at my changes -> http://forums.cpanel.net/f42/xml-api...tml#post601577
    I added an execption for a login error.

Page 1 of 2 12 LastLast

Similar Threads

  1. how to change email password without login
    By aboutblank in forum E-mail Discussions
    Replies: 0
    Last Post: 12-17-2009, 04:08 AM
  2. Force password change before login to cpanel - feature
    By jsnape in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 02-07-2005, 04:21 AM
  3. cpanel login error ( password don´t change )
    By dessiderio in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 09-20-2004, 08:56 PM
  4. Change email password w/o login to cpanel
    By hugo24 in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 05-05-2003, 12:20 AM
bargain