Get all local domains and their aliases

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
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.
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
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.