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.

getting list of email accounts from Whostmgr

Discussion in 'cPanel Developers' started by cpaneldev, Jun 3, 2009.

  1. cpaneldev

    cpaneldev Registered

    Joined:
    Jun 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I need to get a list of all email accounts, forwarders and mailing lists from a cpanel account using a perl script run under the WHM.

    I know that the list of email accounts/forwarders and mailing lists can be retrieved using the api2 (i.e. Cpanel::Email::listpopswithdisk ) but that requires the script to be logged in as that cpanel user. How can I get that information in a WHM addon, i.e. the user is logged in as root on WHM.

    thanks in advance.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Actually, you can call that API2 function via the XML API and login as the root user to the XML API. This means you would only need to use the cPanel username (not their password) as a parameter to the XML API to fetch information about that cPanel account.

    The XML API has a listaccts function you can call to gather a list of all the cPanel users you have on a server. You can build a script that loops through all those users to gather the information you need.
     
  3. cpaneldev

    cpaneldev Registered

    Joined:
    Jun 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    could you provide a snippet that shows how to make the call from perl without the password and put the list of pop accounts into an array?

    thanks.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I'll leave the Perl coding to you, but I'll help with our APIs. If you take the listpopswithdisk example we provide and replace port 2083 with 2087, and HTTP authenticate as the WHM user rather than a cPanel user, you've got the API code you need. Here's our listpopswithdisk example:

    CallingAPIFunctions < AllDocumentation/AutomationIntegration < TWiki
     
    #4 cPanelDavidG, Jun 5, 2009
    Last edited: Jun 5, 2009
  5. cpaneldev

    cpaneldev Registered

    Joined:
    Jun 3, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    ah thanks, switching to port 2087 and getting the whm "hash" did the trick.

    One more question: I get the list of accounts, but the password for each pop account is not part of the results. How can I get the password for each pop account as well?

    thanks.
     
  6. eeadmin

    eeadmin Well-Known Member

    Joined:
    Oct 21, 2004
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Dallas, TX
    Exactly what I was looking for

    Thanks this was exactly what I was looking for! We are trying to better integrate our customer info into other applications.
     
  7. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    These are stored in one way encrypted hashes on your server, meaning that you cannot retrieve them, only change them.
     
Loading...

Share This Page