Just a basic expansion on the code line given earlier in this thread
so it functions as a simple global mail account listing script:
Code:
#!/bin/bash
IFS="$"
cd /home #Just a nice starting point
ls /var/cpanel/users | while read MUSER; do
MHOME=$(grep "${MUSER}:" /etc/passwd | cut -d':' -f6 | head -1)
cd ${MHOME}/mail/
ls -a | grep '@' | awk '{print $2}' FS="." | replace '_' '.'
done
Basically reads the list of valid usernames and home directories
of each of the users on the server and then displays all the email
accounts that have been created for each irregardless of where the
home folders are actually stored for each account.
Don't forget that this will only give you a list of email accounts,
to find out if any additional mail aliases have been setup or alternate
names for these accounts, you will want to also look at each of
the files listed under /etc/valiases where you will find a file named
for each domain on the server and in that file the list of aliases
that have been setup for that specific domain.