Mass update 'contact email' address of all cPanel accounts Print

  • cpanel, whm, centos, rhel, red hat, contact email, api
  • 4

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.

 

  1. Login to your cPanel server via SSH using root, or an account that can attain root priviledges

  2. Quickly create a shell script using nano:
    nano emailupdate.sh
  3. 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
  4. Modify youremail@domain.com for the address you wish to update
  5. Exit nano:
    CTRL + X then press Y to save changes and hit RETURN
  6. Run  the script:
    sh emailupdate.sh

Was this answer helpful?

« Back