The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Email - Possible external link / XML-API

Discussion in 'cPanel Developers' started by drfb, Jan 10, 2009.

  1. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    I posted a reply to a thread { http://forums.cpanel.net/showthread.php?t=103105 } but no-one has replied so i thought that i would try a new one..
    ---------------------
    Email - possible external link

    --------------------------------------------------------------------------------

    I would like to know if there is an external link for allowing users to change passwords?
    I want to create a form within Joomla and make it so the users only need to enter their new password details and when they click on submit it changes the password.
    I have elderly people using the site and currently i'm not willing to teach them how to use webmail (they get it sent to home computer within outlook)..
    I would also like to know if there are easier ways for members to log into webmail if in the future i get around to teaching them. For example if i want them to only log into squirrell mail or round cube that all they need to do is type in mydomain.com/webmail and it takes them straight to their inbox.
    { Sorry bout all the questions here but i had no where else to go }
    My actual end result that i am wanting if for the following:
    ** Users log into site (joomla)
    ** They click on link (webmail) that loads within an i-frame (using thier login details from joomla)
    ** Users want new password (they click on link, complete form by entering new password and click submit.)
    ** This password change will then change password within Joomla and Email.

    Sorry if this was alot to ask within the forum but i really needed some proper answers due to so many people having their opinions on search engine results.

    EDIT

    ** I am a reseller with access to WHM/CPanel
    ** My users have access to their Webmail Screen only (in cpanel)

    ALSO
    I've been looking around a bit more and seen a thing called XML-API but not 100% sure how to set this stuff up.. I'm not a programmer as such but once some-one has built scripts (php,cgi,perl) etc i am pretty good at re-designing things.. What i'm trying to say is that if someone can make the forms or whatever will work then i can customise them to work with things that i need them to (hopefully).. :confused::eek:

    Thanks In Advance
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,455
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    In Tweak Settings in WHM you could enable the option under system for:
    Allow cPanel users to reset their password via email which will enable the link on that failed login page. (this option may not be available to you as a reseller)
     
  3. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    Is there no-one else that could assist with this query?

    How do i set-up XML-API things?

    please refer to my original post above..
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Are you changing a cPanel user's password or a webmail user's password? It sounds from your description that you are changing a webmail user's password.

    As for directly linking to Squirrelmail (or any specific webmail client), I am not aware of any supported methods for doing so other than using the built-in autoload functionality.
     
  5. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    I am wishing to enable to members to change their webmail password using a form that i put onto my website.. that way i can code it into the page so that when they change their password to access the website it also changes their password for webmail..
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    The API1 call for changing the password for an email account is:

    Code:
    <cpanel Email="passwdpop(email,password,quota,domain)">
    email is the portion of the email address before the @ sign. For example: user in user@example.com

    password is their new password

    quota is their email quota

    domain is the domain of their email account, the portion after the @ sign. For example, example.com in user@example.com

    This API1 function call can be called from the XML API. The XML API has its own function call for changing the password for an account.

    You can view the documentation for the XML API at:

    http://cpanel.net/plugins/xmlapi/

    Additionally, there are many code samples utilizing our APIs around these community forums.
     
  7. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    Oh Okay, i get you on this bit Thank-you..
    And now how do i insert this into my site?
    do i have to create a perl/cgi file to connect to CPanel or WHM?
    I'm currently going through the 'http://cpanel.net/plugins/xmlapi/' site but
    having difficulties finding what i need..

    Any help would be fantastic..
    As stated previously i'm a great coder in perl/cgi/php but not an expert.. I can't really create programs as such but i can dig through them and modifiy existing ones fairly well to get them to do what i need them to..
    I love OpenSource you have so much opportunity..
     
  8. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
  9. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Heres the function you are looking for:

    PHP:
    function Email_passwdpops($user,$email,$pwd,$quota,$domain) {
        
    $this->connect("/xml-api/cpanel?user=$user&xmlin=<cpanelaction><module>Email</module><func>passwdpop</func><apiversion>1</apiversion><args>$email</args><args>$pwd</args><args>$quota</args><args>$domain</args></cpanelaction>");
        
    $xmlstr=$this->getOutput();
        if(
    $xmlstr=='') {
            
    $this->errors[]='No output.';
            return 
    false;
        }
        
    $this->disconnect();

        if(
    $xmlstr) {
            
    $xml = new SimpleXMLElement($xmlstr);
            return 
    $xml;
        } else {
            
    $this->errors[]='Some errors occured.';
            return 
    false;
        }
    }
     
  10. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    Do i just setup that coding in my php?
    i can do that quite easily but how do i tell '$this->connect' how to actually connect to the users webmail cpanel?
    if i typed the URL detailswith the arguments after '$this->connect' it wouldn't work would it?
    Does it need to log into Cpanel as a once off thing first/somehow?

    Also i am attempting to view the site you mentioned {http://phpclasses.getwebactive.com/b...kage/4150.html} but it is not loading for some unknown reason..

    I appreciate you assisting me here..
    Thanks
     
  11. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    Hmmm i have had some success..
    I have created 2 files as per the: http://phpclasses.getwebactive.com/browse/package/4150.html

    I have also added the following 2 lots of coding..

    CODE 1.. added to whm.php
    Code:
            function Email_passwdpops($user,$email,$pwd,$quota,$domain)
            { 
                    $this->connect("/xml-api/cpanel?user=$user&xmlin=<cpanelaction><module>Email</module><func>passwdpop</func><apiversion>1</apiversion><args>$email</args><args>$pwd</args><args>$quota</args><args>$domain</args></cpanelaction>"); 
                    $xmlstr=$this->getOutput(); 
                    if($xmlstr=='')
                    { 
                          $this->errors[]='No output.'; 
                          return false; 
                    } 
                    $this->disconnect(); 
    
                    if($xmlstr)
                    { 
                          $xml = new SimpleXMLElement($xmlstr); 
                          return $xml; 
                    }
                    else
                    { 
                          $this->errors[]='Some errors occured.'; 
                          return false; 
                    } 
            }  
    
    CODE 2.. A Test page i created/modified..
    Code:
    <?php
    //include the whm class file.
    require_once('whm.php');
    
    // create a new instance of whm class
    $test= new whm;
    
    //initilize the whm object 
    //you can use you hostname or an IP below 
    //you can find you whm hash when yopu login into your whm account clickong on "Setup Remote Access Key" link.
    $test->init('whmdomain','whmusername','Hashaccesskey');
    
    //This will output the cpanel/whm version.  
    $version= $test->version();
    echo "Cpanel/whm version is: $version <br>";
    
    $test->Email_passwdpops($user,emailusername,newpwrd,10,domain.com.au);
    
    ?>
    
    Now what i can't work out is that the above 2 files seem to work fine in showing me the version details..
    However i can not get them to change the password for my clients webmail.

    Can you please check the above and see what i am doing wrong..

    What you may be able to tell me also is what username should i be placing into the 'CODE 2' $user field.. i would say maybe that is what i am doing wrong and it wont log me in..??
     
  12. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    $user is the cpanel username. Assign the call into a variable like:

    $result = $test->Email_passwdpops($user,emailusername,newpwrd,10,domain.com.au);

    Then you can do a print_r($result) to see what it outputs.
     
  13. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    I did the following:
    Code:
    $result = $test->Email_passwdpops(cpanelmainusername_notemailusername,emailusername,newpwrd,10,domain.com.au);
    
    if($result)
    {
    	//print the result set
    	print_r($result);
    }
    else
    {
    	//You can get the errors like this.
    	print_r($test->errors);
    }
    and the result was:
    Code:
    Cpanel/whm version is: 11.24.2 
    SimpleXMLElement Object ( [module] => Email [func] => passwdpop [type] => event [source] => internal [apiversion] => 1 [data] => SimpleXMLElement Object ( [result] => SimpleXMLElement Object ( ) ) )
    The results got the version as it was called earlier in the code..
    I tried running the script with:
    $user = cpanel main user id (admin user)
    $user = webmail user name (the person trying to change their pwrd)
    But both of the results were the same. (didn't work but still got version)

    I went to log on with the webmail user and the password did not change..
    Also the quota did not change as i tried that aswell.

    Thanks for your help so far, but where do i go from here?
    Do the results mean that the action isn't being processed?
    Is my script even logging into Cpanel or is it just getting the Cpanel Version from the main page without having to log in??
     
  14. drfb

    drfb Member

    Joined:
    Jan 8, 2009
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    Hi All,
    I still haven't had a solution to this request at this stage..
    I was wondering if there was anyone that could help me with the above..

    Thanks
     
  15. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I cannot speak to whatever code you are using, but as far as our APIs go, they require a cPanel username (for the cPanel account in which the mail account resides) and a mail username (the part of an address before @, for example: test for test@example.com).
     
Loading...

Share This Page