QmailtoasterMain Page | About | Help | FAQ | Special pages | Log in

Printable version | Disclaimers | Privacy policy | Latest revision

Enable/Disable POP3/SMTP/IMAP/Webmail access for a whole domain

(Difference between revisions)

 
Line 16: Line 16:
  # USAGE> ./disable_domain.sh yourdomain.net
  # USAGE> ./disable_domain.sh yourdomain.net
-
domain=$1
+
domain=$1
-
vpmdir=/home/vpopmail
+
vpmdir=/home/vpopmail
-
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
+
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
-
for acctpath in $acctlist;  
+
for acctpath in $acctlist;  
-
do
+
do
-
  account=${acctpath##*/}
+
    account=${acctpath##*/}
-
  address=$account@$domain
+
    address=$account@$domain
-
  echo "changing $address"
+
    echo "changing $address"
     $vpmdir/bin/vmoduser -p -s -w -i -r $address
     $vpmdir/bin/vmoduser -p -s -w -i -r $address
-
done
+
done
Line 38: Line 38:
  # USAGE> ./UNDO_disable_domain.sh yourdomain.net
  # USAGE> ./UNDO_disable_domain.sh yourdomain.net
-
domain=$1
+
domain=$1
-
vpmdir=/home/vpopmail
+
vpmdir=/home/vpopmail
-
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
+
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
-
for acctpath in $acctlist;  
+
for acctpath in $acctlist;  
-
do
+
do
   account=${acctpath##*/}
   account=${acctpath##*/}
   address=$account@$domain
   address=$account@$domain
   echo "changing $address"
   echo "changing $address"
     $vpmdir/bin/vmoduser -x $address
     $vpmdir/bin/vmoduser -x $address
-
done
+
done

Latest revision as of 00:38, 7 August 2012

Below is a set of scripts to enable/disable POP3, SMTP, IMAP/Webmail and relaying for every user in a given domain.

Create a script file, paste the code, and chmod +x it and you are done.

Enjoy!

[Credits to Eric Shubert for the original scripting.]



#!/bin/sh
# script to change settings for all users in a domain
# and disable POP3/SMTP/IMAP/Webmail Access.
# SM - 24/11/10
# USAGE> ./disable_domain.sh yourdomain.net
domain=$1
vpmdir=/home/vpopmail
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
for acctpath in $acctlist; 
do
   account=${acctpath##*/}
   address=$account@$domain
   echo "changing $address"
   $vpmdir/bin/vmoduser -p -s -w -i -r $address
done



#!/bin/sh
# script to revert change settings for all users in a domain
# and enable POP3/SMTP/IMAP/Webmail Access.
# SM - 24/11/10
# USAGE> ./UNDO_disable_domain.sh yourdomain.net
domain=$1
vpmdir=/home/vpopmail
acctlist=$(find $vpmdir/domains/$domain -mindepth 1 -maxdepth 1 -type d)
for acctpath in $acctlist; 
do
  account=${acctpath##*/}
  address=$account@$domain
  echo "changing $address"
   $vpmdir/bin/vmoduser -x $address
done