Recently a customer approached us about bulk changing all of their cPanel account's contact email addresses. They wanted to receive all cPanel and AutoSSL notifications to a particular logging email account. The cPanel / WHM panels do not have any bulk update feature inbuilt, though fortunately the WHM API can be used to achieve this task with a little shell sourcery.
- Login to your cPanel server via SSH using root, or an account that can attain root priviledges
- Quickly create a shell script using nano:
nano emailupdate.sh
- Copy and paste the following code into nano:
#!/bin/sh
for i in `cut -f2 -d' ' /etc/trueuserdomains|sort`
do
/usr/local/cpanel/bin/whmapi1 modifyacct user=${i} contactemail=youremail@domain.com
done - Modify youremail@domain.com for the address you wish to update
- Exit nano:
CTRL + X then press Y to save changes and hit RETURN
- Run the script:
sh emailupdate.sh