Mass Update Default Webmail

Patrick Heinz

Active Member
Mar 14, 2015
34
1
8
Brasil
cPanel Access Level
Root Administrator
Twitter
Hello,

I manage a shared server and I let users choose between Horde and Roundcube.
Is there a way to update all email accounts for one domain only to use Horde or Roundcube?
I already know that one option is to access each email account and change the default application. But, is there a way to do this massively?

Where cPanel keeps this information (about default webmail per account)?

Thanks.
 

cPLevey

Technical Analyst Manager
Staff member
Dec 3, 2015
44
8
133
Houston, TX
cPanel Access Level
Root Administrator
Hello Patrick,

Unfortunately, I'm not aware of an easy way to do this on a massive scale. I highly recommend submitting a feature request to see such functionality in a future version of cPanel. However, this can be done with the use of our UAPI and a loop.

The default webmail application for each email account is stored in the following path:
Code:
/home/cpaneluser/.cpanel/nvdata/[email protected]_default_webmail_app
Manually creating each of these files would be almost as time consuming as logging into each email account. To automate this a bit, we can use the following UAPI functions:
Our loop would need to gather a list of all email accounts for a cPanel account (Email::list_pops) and then set the desired default webmail app for each of those email accounts (NVData::set).

I threw together the following, which worked as expected in my testing environment.

Code:
cpanelaccount="forumuser";
webmailapp="roundcube";

for emailaccount in $(uapi --user=$cpanelaccount Email list_pops |grep email: |awk '{print $2}' |sed 's/@/%40/g'); do uapi --user="$cpanelaccount" NVData set names="$emailaccount"_default_webmail_app "$emailaccount"_default_webmail_app="$webmailapp"; done
You will need to replace "forumuser" with your desired cPanel account, and replace "roundcube" with your desired webmail app.

I hope this helps!