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.

having problems with API1 Query addpop: Invlid email address error

Discussion in 'cPanel Developers' started by asmith4, Oct 18, 2011.

  1. asmith4

    asmith4 Registered

    Joined:
    Oct 18, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    This is my first post on this forum, first off thanks for developing such a useful class for Cpanel. I have got just about every function I require working but am having some problems trying to add an email account with addpop.

    below is how I am trying to use the addpop method in the class:

    XMLAPI Object created with the following code snippet: (uses user= root, and root password)
    $xmlapi = new xmlapi($CP_HOST, $CP_USER, $CP_PASSWORD);

    $username = 'CP_User';

    $args['email_user'] = 'test';
    $args['email_password'] = 'emailpassword';
    $args['email_quota'] = 250;
    $args['email_domain'] = 'mydomain.com';

    $emailAccResult = $xmlapi->addpop($username, $args);

    XMLAPI Class addpop method executes with the following line of code:

    return $this->api1_query($username, "Email", "addpop", $args);

    Each time I try to add an email account returns the following output:

    SimpleXMLElement Object ( [module] => Email [func] => addpop [type] => event [source] => internal [apiversion] => 1 [data] => SimpleXMLElement Object ( [result] => Sorry, the given email address is invalid. ) [event] => SimpleXMLElement Object ( [result] => 1 ) )

    I have tried using

    $xmlapi->password_auth("relatedcpanelusername",$root_pass);

    but just the same output. Seems to be allowing me access but I can't figure out why the says the email address is invalid

    I have also tried to create new email account directly through cpanel with the details using in the script and creates this no problem.

    Any help would be appriciated.

    Thanks Adam.
     
  2. asmith4

    asmith4 Registered

    Joined:
    Oct 18, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi all,

    Just found the solution to my problem and thought I would post it here in case it can help anyone else.

    It was something simple, as these things often are :)

    The creation of the email account was failing with the error 'Sorry, the given email address is invalid'

    The reason it turns out was that addpop is an API1 function and the $args array I was passing to the addpop function was an associative array.

    API1 does not use associative arrays like API2 does which I noticed when reading some other unrelated posts on this forum.

    Once I changed the $args array to a standard numbered array worked like a charm.

    As i say I am just reporting this here in the hopes it will help someone else, I found the documentation was not very clear on this point, or at least I didn't find it that clear.

    Many thanks again to the developers for creating such a useful CPanel API class though.
     
Loading...
Similar Threads - having problems API1
  1. htmldesign
    Replies:
    4
    Views:
    498

Share This Page