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.

Cannot Create New Email Accounts with XML API Script

Discussion in 'E-mail Discussions' started by christsealed, Apr 27, 2011.

  1. christsealed

    christsealed Registered

    Joined:
    Apr 27, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I have a two tiered question:

    First, I have a VPS on which I am expecting to sell hosting accounts. I don't really want users having access to cPanel, yet I want to enable them to create email accounts through an application I will build.

    I found your script as represented below and it seemed like the perfect solution for me.

    PHP:
    $account "dave";
    $account_pass "d4v3sSecret!";

    $email_user "mr_dave";
    $email_password "my_s3cr3t_pop!passwd";
    $email_domain "dave.com";
    $email_quota '0';

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($account$account_pass);  <-- USE USER ACCOUNT AUTH
    $xmlapi
    ->set_output('xml');

    $result $xmlapi->api1_query($account"Email""addpop", array($email_user$email_password$email_quota$email_domain) );
    My problem is that although I can get the account name by exploding getenv("DOCUMENT_ROOT"), I have no way of getting their password information, and so I can't authenticate the request dynamically as I need to.

    I need to find a way to extract their password and assign it to a variable to be used in authentication.

    Part two of my problem is that I've tried doing it with static values:

    PHP:
    include("xmlapi.php");

    $account_pass "xxxx";
     
    $ip getenv('REMOTE_HOST');
     
    $account "xxxx";
    $email_user "xxxx";
    $email_password "xxxx";
    $email_domain "xxxx";
    $email_quota '0';
    //
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($account$account_pass);  
    $xmlapi->set_output('xml');
    //
    $result $xmlapi->api1_query($account"Email""addpop", array($email_user$email_password$email_quota$email_domain) );
    And I'm still getting an error message:


    Fatal error: Uncaught exception 'Exception' with message 'No host defined' in /home/xxxx/public_html/xmlapi.php:218 Stack trace: #0 /home/xxxx/public_html/api1_example.php(36): xmlapi->__construct(false) #1 {main} thrown in /home/xxxx/public_html/xmlapi.php on line 218

    I'm pretty new to using this API, but I thought I followed the example explicitly. Is there anything wrong with my logic? Is there something else I need to try?

    My cPanel version is 11.28.87

    Thanks in Advance,

    Aaron -
     
    #1 christsealed, Apr 27, 2011
    Last edited: Apr 27, 2011
  2. christsealed

    christsealed Registered

    Joined:
    Apr 27, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    This has been resolved. For weeks I had been getting emails about my VPS host not resolving correctly. When I talked to my hosting provider, they assured me not to worry about it, everything was fine and it was working normally.

    Yet, the error that this API threw made me realize that this might be the issue. Sure enough, I reset my resolvers through WHM and voila! Success.

    Then the issue of the cURL fatal exception came up. I checked my PHP configuration in WHM and realized that cURL with SSL was set up, but cURL was not. I recompiled through easyapache with both options checked and BOOM! Worked like a charm.

    Just thought that might be helpful to someone in the same situation.

    If you're getting cURL exceptions thrown at you, check your cURL installation. If it's saying No Host Defined, check your Host Resolvers in WHM. This is a great class! When I saw that my issues had been cleared up and my script was working, AHHHHHHHH! I was in heaven!
     
Loading...

Share This Page