Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mass Update Default Webmail

Discussion in 'E-mail Discussions' started by Patrick Heinz, Oct 19, 2016.

  1. Patrick Heinz

    Patrick Heinz Active Member

    Joined:
    Mar 14, 2015
    Messages:
    32
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    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.
     
  2. cPLevey

    cPLevey Technical Analyst Supervisor
    Staff Member

    Joined:
    Dec 3, 2015
    Messages:
    44
    Likes Received:
    8
    Trophy Points:
    83
    Location:
    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@domain.tld_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!
     
    jonam_mafia and Patrick Heinz like this.
  3. Patrick Heinz

    Patrick Heinz Active Member

    Joined:
    Mar 14, 2015
    Messages:
    32
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Brasil
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello David,

    Thanks a lot!!

    That's what I was looking for.
     
  4. cPLevey

    cPLevey Technical Analyst Supervisor
    Staff Member

    Joined:
    Dec 3, 2015
    Messages:
    44
    Likes Received:
    8
    Trophy Points:
    83
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page