get list of email accounts
Hi,
I was wondering if it was possible to get a listing of email accounts per cPanel account in an easy way? I think you could maybe list them under /home/mail maybe, but was wondering if there was a command line script or something that listed all email accounts on the system. The below link shows /scripts/addpop to add an email via cli. I was wondering about something like 'getpop'.
-
Hey there! The API call is your best best as there isn't a flat file like what you mentioned. You could see individual accounts with their respective directories in /home/usrename/mail/domain.com, but that's not nearly as pretty of a list of what the API creates. 0 -
thanks @cPRex 0 -
Sure thing! 0 -
for i in $(find /var/cpanel/users -type f | egrep -o '[a-zA-Z0-9]+$' | grep -v system);do whmapi1 list_pops_for user=$i;done this will work to get all email accounts 1 -
I found this in the api, this can be scripted to cycle through the accounts.
uapi --user=account Email list_pops
was hoping for a flat file like /etc/localdomains or /etc/userdomains (or something like that, or a pre-existing script/command that would run on the whole system without scripting)
Thank you. I was looking for it, too! So you can also use:whmapi1 list_pops_for user=[username]0 -
for i in $(find /var/cpanel/users -type f | egrep -o '[a-zA-Z0-9]+$' | grep -v system);do whmapi1 list_pops_for user=$i;done this will work to get all email accounts
just to note that you can print the output of the readout to a file by doing the following: for i in $(find /var/cpanel/users -type f | egrep -o '[a-zA-Z0-9]+$' | grep -v system);do whmapi1 list_pops_for user=$i >> mailservice.txt;done Just change the name for the mailservice.txt to whatever you want the file to be. To note it will print the file to the directory that you are in.0
Please sign in to leave a comment.
Comments
6 comments