Add to Favourites Add to Favourites    Print this Article Print this Article

I need a list of all email accounts on the system

If you need to get a list of all created E-Mail accounts on your server, including domain pointers, you can use this basic script:

#!/bin/sh
for d in `cat /etc/virtual/domains`; do
{
       #system account
       S=`grep "^${d}:" /etc/virtual/domainowners | cut -d: -f2 | awk '{print $1;}'`
       if [ "${S}" != "" ]; then
               echo "${S}@${d}";
       fi

       if [ ! -s /etc/virtual/$d/passwd ]; then
               continue;
       fi

       for e in `cat /etc/virtual/$d/passwd | cut -d: -f1`; do
       {
               echo "${e}@${d}";
       };
       done;
};
done;
exit 0;


Was this answer helpful?

Also Read