Saturday, February 11, 2017

Find List of email ids belong to all domains exist in cpanel server

Unfortunately there is no built-in way in WHM/cPanel to list every POP3/IMAP account for every domain in one listing, however, using the command line and our built-in API system, you can run a query to list true email accounts:

1. as root change to /var/cpanel/users
# cd /var/cpanel/users

2. run the following one-line query against our API system:

# for file in *; do whmapi1 list_pops_for user=$file 2>/dev/null | grep \@ | grep -F @; done

This will result in an output such as:

root@server [/var/cpanel/users]# for file in *; do whmapi1 list_pops_for user=$file 2>/dev/null | grep \@ | grep -F @; done
- a@domain1.com
- x@domain1.com
- belle@domain2.com
- brian@domain3.com
- demos@domain3.com
- greypromo@domain3.com
- info@domain4.com
- kage@domain5.com
- news@domain6.com
- release@domain6.com
- sales@domain6.com

and so forth. These are all of the true email accounts on for every domain on your server.

Hope this information helps!