Create bulk email accounts in cPanel

Create bulk email accounts in cPanel

Lately I’ve been dealing a lot with email accounts in cPanel: Bulk change cPanel mailbox quota for all email ✉️ accounts and Bulk delete ✉️ email forwarders in cPanel.

Here is how to bulk create email accounts in cPanel under a single domain name.

First, let’s create a list of user accounts and passwords separated by colon:

cat users-list.txt
user1:3HVQw6KzSy28-tuK
user2:#2?kGZdr8N)e+K}S
user3:&Qa[;K49>%Dh4G)"
user4:'Ls;z/4;.pCT"=,K
user5:7N\[]m(hc![/,'b@
user6:%mBpwuz6R"+=EF-S
user7:SA_;k<,)j6`/V.6M

Then a shell script

for i in `cat users-list.txt`; do /scripts/addpop `echo $i|awk -F":" {'print $1'}`@domain.com  `echo $i|awk -F":" {'print $2'}`;done

This will set unlimited quota for all acoounts, to set a specific mailbox quota use -quota option:

for i in `cat users-list.txt`; do /scripts/addpop `echo $i|awk -F”:” {‘print $1’}`@domain.com  `echo $i|awk -F”:” {‘print $2’}`  –quota 100M;done

Email accounts will be created and the output will be::

user1@domain.com
user2@domain.com
user3@domain.com
user4@domain.com
user5@domain.com
user6@domain.com
user7@domain.com

To bulk delete all email accounts from a list, create another list:

cat delete-list.txt

then put the accounts in the following format:

user1@domain.com
user2@domain.com
user3@domain.com
user4@domain.com
user5@domain.com
user6@domain.com
user7@domain.com

and then use the following shell script:

for i in `cat  delete-list.txt`; do /usr/local/cpanel/scripts/delpop $i ;done

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.