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.

Looking for cpanel api to grab email address from whm with php

Discussion in 'cPanel Developers' started by housefire, Feb 21, 2009.

  1. housefire

    housefire Member

    Joined:
    Jun 24, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    We are working on a new billing system, and want to use a php api to connect to whm and grab the email address for a specific domain.

    Anyone done this before?
     
  2. jBillu

    jBillu Member

    Joined:
    Oct 21, 2008
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Re: "Looking for cpanel api to grab email address from whm with php"

    Although I am not aware of cPanel API for this purpose but in case if you fail to find required API, there is a manual way to retrieve this information using PHP script.

    I don't really think cPanel/WHM stores actual email account names in file(s) on the server. You may have to parse couple of files and retrieve directory contents in order to accomplish it. If you are interested in doing it then here is what want to fetch from files/directories.

    Each email account exists in the form of a directory under '/home/USER/mail/DOMAIN.TLD/' in the form '/home/USER/mail/DOMAIN.TLD/EMAIL'. Let us parse this path one by one.

    => The 'USER' is actual cPanel account's Username. If your script doesn't know about the User of a particular domain then it can be retreived from '/etc/userdomains' file. Each line of this file is of format "domain.TLD: user"

    => The 'DOMAIN.COM' is actual domain name whose email accounts you want to retrieve

    => The 'EMAIL' is in fact the prefix, the part that appears before the '@' sign. Suppose if you have an email account of the name 'jbillu@domain.com' then the EMAIL refers to 'jbillu'.

    To summarize, suppose there is a domain 'domain.com' with cPanel Username 'user' and email account 'jbillu' then the path will be '/home/user/mail/domain.com/jbillu'. Hope this will help.
     
    #2 jBillu, Feb 22, 2009
    Last edited: Feb 22, 2009
  3. 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
    ** Moved Thread to Developer Section **
     
  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
    The listaccts function in our XML API will provide you with the primary e-mail address set for a cPanel account.
     
Loading...

Share This Page