List all email accounts with size and restriction status
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:
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:
Can anyone provide assistance? Preferably output would be a CSV.
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:
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.
-
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? 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.0 -
find
output all the cpanel users without error. Thanks for the API docs. I'll see what I can do with that.0 -
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! 0
Please sign in to leave a comment.
Comments
3 comments