List mailboxes on WHM/cPanel server


Screenshot from 2013-09-25 16:40:53

WHM mailboxes can be listed with the following script:

#!/bin/bash
for f in $(ls |grep -v "^\.\|virtfs\|lost+found\|cpeasyapache\|quota.user");
      do
         f2=$(echo $f |sed 's/\/$//g');
         for box in $(ls "$f"/mail/ |grep -v "^\.\|new\|cur\|sent\|tmp" );
               	do m=$(ls -l /home/"$f"/mail/"$box"/ |awk '{print $9}' |grep -v "^\." |sed '/^$/d');
               	if [ "$m" != "" ];
               	then
                           	for m2 in $m;
                           	do
                                       	echo "$m2"@"$box"
                           	done;
               	fi
         done;
done;
Share Button

Leave a Reply

You must be logged in to post a comment.