Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    May 2010
    Location
    Mumbai, India
    Posts
    17

    Default Accessing delpop function via PHP

    on my web server delpop function is not working but I tried php code for addpop, passwdpop and editquota these functions are working. Can anybody tell me thye solution.
    Thanks.

  2. #2
    Member
    Join Date
    Jan 2008
    Posts
    141

    Default

    Kindly check the apache error logs for the exact error message when accessing your php page. You can check it from /usr/local/apache/logs/error_log.

  3. #3
    cPanel Quality Assurance Analyst cPanelDon's Avatar
    Join Date
    Nov 2008
    Location
    Houston, Texas, U.S.A.
    Posts
    2,555
    cPanel/Enkompass Access Level

    DataCenter Provider

    Default

    Quote Originally Posted by devendradb View Post
    on my web server delpop function is not working but I tried php code for addpop, passwdpop and editquota these functions are working. Can anybody tell me thye solution.
    Thanks.
    Please let us know greater detail so that the issue can be more accurately diagnosed:
    1.) What is the specific PHP code being used?
    2.) When using the PHP script, are there any errors logged? Look in both the PHP error_log (if one exists, perhaps in the same directory as the PHP script being executed) as well as looking in the cPanel error_log in "/usr/local/cpanel/logs/".
    3.) What method is being used to authenticate via the PHP script? Are you using a cPanel username and password, or a hash generated via WHM at the following menu path? ( WHM: Main >> Cluster/Remote Access >> Setup Remote Access Key )

    I recommend referring to our official documentation, as noted below:
    Last edited by cPanelDon; 05-18-2010 at 09:29 PM. Reason: Clarification

  4. #4
    Member
    Join Date
    May 2010
    Location
    Mumbai, India
    Posts
    17

    Default Delpop code

    Hi, I am using following code for using delpop function
    http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/dodelpop.html?&email=$email&domain=$cpdomain

    instead of dodelpop I tried delpop also but both codes did not return any errors.
    thanks.

  5. #5
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    Hi devendradb,

    I suppose that the sample URL that you provided *might* work, however that is not the recommended way.

    Like Donald suggested, you should make you requests using an API call. One way we recommend doing this is by using the XML-API binary and passing the API1 or API2 call to it. It's easy, you can do it remotely or on the localhost.

    One of the most convenient ways to make send requests to the XML-API binary is by using the XML-API PHP client class.
    http://sdk.cpanel.net/lib/xmlapi/php..._v1.0.5.tar.gz

    Once you have that, you can do something like this:
    Code:
    <?php
    include("xmlapi.php");
    
    $ip = "10.1.1.1";
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->set_port('2083');
    
    $cpuser = "someone";
    $cppass = "pass123";
    $xmlapi->password_auth($cpuser,$cppass);
    
    //$xmlapi->set_debug(1);
    
    // to add a pop email //
    $add = array( 'email' => "testname", 'password' => "testpass123", 'domain' => "thisdomain.com", 'quota'=>0);
    $xmlapi->api2_query('someone','Email','addpop',$add);
    
    // to delete a pop email //
    $del = array( 'email' => "testname", "domain" => "thisdomain.com");
    $xmlapi->api2_query('someone','Email','delpop',$del);
    
    ?>
    By using the PHP class, you can easily handle the authentication. If you don't use the PHP class, then you could make the same URL requests -- just make sure to send the proper authentication headers.

    An example URL of delpop: (conveniently generated from debug mode in the PHP client class)
    Code:
    URL: https://10.1.1.1:2083/xml-api/cpanel
    
    DATA: email=testname&domain=thisdomain.com&user=someone&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=delpop&cpanel_xmlapi_apiversion=2
    
    Authentication Header: Authorization: Basic c29tZW9uZZpmYXNzMTIz
    Regards,
    -David
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  6. #6
    Member
    Join Date
    May 2010
    Location
    Mumbai, India
    Posts
    17

    Default Delpop

    Thanks David. This api worked fine thank you very much.
    - Devendra

  7. #7
    Member
    Join Date
    May 2010
    Location
    Mumbai, India
    Posts
    17

    Default Display data returned by API

    Hi David,
    Now I am trying new API functions but I am not able to extract correct data out of response.
    example: I am using listpopswithdisk API but I am not able to seperate each user or email id out of returned simpleXMLElement Object.
    I can just display whole string. (print_r($r))
    thanks in advance.

  8. #8
    cPanel Staff cPanelMatt's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    please see:

    PHP: SimpleXML Basic usage - Manual

    so, if you wanted to list out all of the usernames, you would want to do something like:

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

    $ip "127.0.0.1";
    $root_pass "testpassword";

    $account "someuser";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_output("simplexml");

    $resp $xmlapi->api2_query($account"Email""listpopswithdisk" );
    foreach ( 
    $resp->data as $email_user ) {
        print 
    $email_user->email "\n";

    Matt Dees
    Integration Developer
    cPanel, Inc.
    cPanel Integration Blog

  9. #9
    Member
    Join Date
    May 2010
    Location
    Mumbai, India
    Posts
    17

    Default

    Hi Matt,
    Thanks for the help. I tried the code, now I got the correct result. i can now able to put each user in <select> drop down menu.
    Thanks.

Similar Threads & Tags
Similar threads

  1. API2 'delpop' problem
    By bmett in forum cPanel Developers
    Replies: 3
    Last Post: 08-09-2010, 07:01 PM
  2. Accessing delpop function via PHP
    By devendradb in forum E-mail Discussions
    Replies: 1
    Last Post: 05-12-2010, 02:23 AM
  3. Accessing AWSTAT IN CPANEL using php
    By francis_tudlong in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 08-31-2009, 07:39 AM
  4. php accessing the log files
    By OMaHTLD in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-01-2005, 10:03 PM
  5. question about accessing acccounting.php.inc
    By teknowebworks in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 03-16-2004, 04:21 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube