List all email accounts with size and restriction status

refueledinc

Member
Jun 17, 2015
8
0
51
Clearwater
cPanel Access Level
Root Administrator
I'm trying to get a list of all email accounts on the server including their disk usage and restriction status (unrestricted, restricted, etc)

I currently use this:
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 gets me a list of email address, but it has two issues:

1. It does not list the size and restriction status
2. It outputs errors, even though it still seems to work:

Code:
warn [Internal Warning while parsing [stdin] 194064] (XID 4yk3gp) The sys
tem failed to create the file “/home2/username/.cpanel/email_accounts.json.lock” (as EUID: 520,
EGID: 533 533) because of the following error: No such file or directory at /usr/local/cpanel/Cpanel
/Email/Accounts.pm line 155.
Can anyone provide assistance? Preferably output would be a CSV.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,597
2,615
363
cPanel Access Level
Root Administrator
Hey there! My first thought on this, is that I don't get those errors on a test machine. Can you run just the find portion and see what output you get that could be causing confusion in the for loop?

Code:
find /var/cpanel/users -type f | egrep -o '[a-zA-Z0-9]+$' | grep -v system
You'll also likely want to look into the user-level API call of Return email accounts with disk information as that shows the disk usage and restriction status in one command.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,597
2,615
363
cPanel Access Level
Root Administrator
Interesting - if "find" didn't give anything odd, I would expect the whole for loop to work well. I'd still try working with that uapi call as that gives you all the information you want in one command, but let us know what you come up with!