In this tutorial, you will learn how to bulk update/change Contact Email for accounts in WHM. This is useful when you have a reseller and want to change the default email address on all of the accounts with a different email address.
If you’re not feeling comfortable using the command line interface, we recommend you to do it manually in WHM.
To do so, navigate to Account Information >> List Accounts area. Here you will see all the accounts listed. Then click on the ‘+’ sign in front of the username then change the contact email for the account(s) that you want.
In case you prefer doing it for a single or few accounts from the command line, you can use:
cpapi2 --user=user CustInfo savecontactinfo [email protected]
How to Bulk Update/Change Contact Email for accounts in WHM
The contact email address for each cPanel account is stored in two different files:
- /var/cpanel/users/user
- /home/user/.contactemail
Let’s say that you need to change an existing contact email: [email protected] and to replace it for all the cPanel accounts with [email protected].
Tired of hassling with hosting management? ChemiCloud is the managed hosting solution designed to save you time and money! 🤓 Check out our web hosting plans!
While you are in your terminal, connected to your server, browse to /var/cpanel/users/:
cd /var/cpanel/users/
And do a grep for “[email protected]” in each file:
grep -irl "[email protected]" .
It will start listing the files that have a match for the search term. E.g:
./user1 ./user2 ./user3
Now you will have to create a text file in /var/cpanel/users/ e.g: users.txt and to add the results of your search using grep command.
Next, we’ll use sed to replace all the instances matching [email protected] with [email protected]. The command line is:
for i in $(cat users.txt); do sed -i 's/[email protected]/[email protected]/g' $i; done
The same steps will need to be applied to do the bulk change of the email stored in /home/user/.contactemail.
I have checked the above article but the .contactinfo file is not reflected in the terminal. But the front end is working fine.