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

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat