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.

check if email account is available?

Discussion in 'cPanel Developers' started by nowayin, Aug 31, 2013.

  1. nowayin

    nowayin Registered

    Joined:
    Aug 3, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    I'm using the XML-API class and I don't see a function to check if an email is available or not.
    I want to check my cPanel to see if that email is taken already, if yes, return true, then if not return false.

    I tried using this function :
    PHP:
    $result $xmlapi->api2_query($account"Email""listpops");
    But it just lists all the email that is on the cPanel account.
    Is there an $arg I can use to check if an email already exist?

    Maybe something like
    $result = $xmlapi->api2_query($account, "Email", "listpops", array($email));
    If the email exist
    return true
    else
    return false

    I've been searching and looking but the functions I found was for WHM.
     
  2. nowayin

    nowayin Registered

    Joined:
    Aug 3, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Never mind I found the solution to my problem.
    What I did was use the API2 and use the function "editquota" to edit the quota of a user. If the edit is successful that means the user already exist in the database, if edit is unsuccessful then the user is not there.

    If anyone happens to stumble upon this tread and is looking for the same thing, here is the code :

    PHP:
    $result $xmlapi->api2_query($account"Email""editquota", array( 'domain' => "domain.com"'email' => "username"'quota' => "1024") );
    Then, to check if the username is taken or not :

    PHP:
    if (strpos($result'not') == true ) {
        echo 
    'available';
    }
    else{
        echo 
    'taken';
    }
    Make sure you set
    PHP:
    $xmlapi->set_output('xml');
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page