To get all the email ID contains for a domain

Below script is to find email accounts for all domains --> to find for one domain fire command like this ---> sh email.sh | grep domain.com


#vi email.sh

#!/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;


execute the above script with  sh email.sh | grep domain

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation