
Did you ever wanted to see how many mailboxes do you serve in total ?
You can see per user listing mailboxes in cPanel, but all of them is a pain. No such feature. It’s easy enough:
1 |
find /home/*/etc -maxdepth 2 -mindepth 2 -name passwd -exec cat {} \; | wc -l |
you can also try:
1 |
find /home*/*/etc -name passwd -exec cat {} \; | wc -l |
Want to check a complete list of all emails ? That’s even better:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash - cat /dev/null > /root/mailaccounts.txt CP_ACCOUNTS=`ls -1A /var/cpanel/users/` for user in `echo -n $CP_ACCOUNTS` do /root/mailaccounts.txt domain=`grep -i ^dns /var/cpanel/users/$user |cut -d= -f2` for dom in `echo -n "$domain"` do PASSWD_FILE="/home/$user/etc/$dom/passwd" if [ -f $PASSWD_FILE ] && [ -s $PASSWD_FILE ] then for mail in `cat $PASSWD_FILE| cut -d":" -f1` do echo "$mail@$dom" >> mailaccounts.txt done fi done done |