Results 1 to 2 of 2

Thread: Cannot Create New Email Accounts with XML API Script

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    Default Cannot Create New Email Accounts with XML API Script

    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 Code:
    $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 Code:
    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 -
    Last edited by christsealed; 04-27-2011 at 03:48 PM.

  2. #2
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    Default Re: Cannot Create New Email Accounts with XML API Script

    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!

Similar Threads

  1. xml-api script works only sometimes?
    By progamerinc in forum cPanel Developers
    Replies: 5
    Last Post: 04-20-2010, 03:52 PM
  2. Replies: 5
    Last Post: 04-10-2009, 06:32 AM
  3. XML-API and controling WHM using remote Perl script - Help!
    By jonathanwww in forum cPanel Developers
    Replies: 1
    Last Post: 06-30-2008, 10:09 AM
  4. Way to create MySql DB with XML-API?
    By dudely in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 08-27-2007, 11:42 AM
  5. How could I write a PHP script to create email accounts?
    By N9ne in forum cPanel & WHM Discussions
    Replies: 4
    Last Post: 04-19-2003, 08:30 PM