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.

Get all local domains and their aliases

Discussion in 'cPanel Developers' started by MACscr, Aug 23, 2013.

  1. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I am needing to find out the simplest way to simply get a list of all main domains and their associated alias domains that accept email on a cpanel server. Unfortunately I cant just scrape the /etc/localdomains list as it doesnt tell me whats aliases to what and it also includes every single subdomain even if no email accounts are even associated with it. I am going to be scripting this up to sync with our external anti-spam gateways. Suggestions?

    Thanks,
    Mark
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    There are no files that will list that information exactly how you need it. You will need to parse that information from multiple files. EX:

    /etc/userdatadomains
    /etc/localdomains

    Thank you.
     
  3. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Yeah, I figured nothing gave me exactly what I wanted, but was hoping I could get some data that I could parse. While /etc/userdatadomains will help me map things out a bit, it unfortunately still leaves me with probably 50% more results than would be needed as 95% of subdomains arent used with email.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    There is no files that will list which subdomains utilize email, however you can review the passwd files within the accounts to see which subdomains have email accounts. EX:

    Code:
    /home/$username/mail/$domain.com/passwd
    Thank you.
     
Loading...

Share This Page