Created
April 9, 2017 15:49
-
-
Save yongkiagustinus/b4eb71bf439c87e7e70706a458dadbbf to your computer and use it in GitHub Desktop.
Bash script to setup email for all cPanel accounts in WHM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Get all domains as array | |
# You can change /etc/trueuserdomains to /etc/userdomains if you want to include the sub domain | |
domains=(`cat /etc/trueuserdomains | cut -d: -f1`) | |
echo "Found ${#domains[@]} domains" | |
echo -e "\n" | |
for (( i=0; i<${#domains[*]}; i=i+1 )) | |
do | |
# Domain variable is ${domains[$i]} | |
# Create email account | |
# Change EMAILUSER to your choice | |
# Change EMAILPASSWORD to your password | |
# Change QUOTA to your mailbox quota in MB (Numeric please) | |
/scripts/addpop EMAILUSER@${domains[$i]} EMAILPASSWORD QUOTA | |
# Uncomment this script if you want to setup email forwarding | |
# This script will automatically append a line on the domain alias file | |
# echo "EMAILUSER@${domains[$i]}: FORWARDTO@MAIL.COM" >> ../etc/valiases/${domains[$i]} | |
echo ">>>>> DONE" | |
echo -e "\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment