User Tools

Site Tools


build:webmail

Webmail

We chose RoundCube after trying a bunch of other webmail applications. Here are some that we tried:

  • Bongo (formerly Hula) - could not get it to install
  • SquirrelMail - old UI is hard to work with
  • Horde (IMP) - complicated setup, does too much
  • Zimbra - too integrated with email servers

RoundCube is well supported, with a good development community and a rich set of plugins.

Installation

First we install the software on the system. We install it into /usr/local/share, so multiple sites can share the installation.

# Install some (optional) prerequisites.
sudo apt-get install php5-mcrypt php5-intl
 
# Set the version we're going to install.
ROUNDCUBE_VERSION='0.8.4'
 
# Download and unpack the software.
wget http://sourceforge.net/projects/roundcubemail/files/roundcubemail/$ROUNDCUBE_VERSION/roundcubemail-$ROUNDCUBE_VERSION.tar.gz/download -O roundcubemail-$ROUNDCUBE_VERSION.tar.gz
tar xfz roundcubemail-$ROUNDCUBE_VERSION.tar.gz
 
# Fix up a path issue in the installer.
sed -i roundcubemail-$ROUNDCUBE_VERSION/installer/index.php -e "s|^define('INSTALL_PATH', .*);$|define('INSTALL_PATH', \$_SERVER['DOCUMENT_ROOT'].'/');|"
 
# Install the software.
sudo mkdir -p /usr/local/share/roundcube/$ROUNDCUBE_VERSION
sudo cp -R roundcubemail-$ROUNDCUBE_VERSION/{.htaccess,*} /usr/local/share/roundcube/$ROUNDCUBE_VERSION
 
# Clean up after ourselves.
rm roundcubemail-$ROUNDCUBE_VERSION.tar.gz
rm -rf roundcubemail-$ROUNDCUBE_VERSION

Then we set up the database for a particular instance.

ROUNDCUBE_POSTGRESQL_DB='webmail_boochtek'
ROUNDCUBE_POSTGRESQL_USER="roundcube_$(openssl rand 3 -base64 | tr '+/' '-_')"
ROUNDCUBE_POSTGRESQL_PASSWORD="$(openssl rand 15 -base64 | tr '+/' '-_')"
sudo sudo -u postgres createuser -SDR $ROUNDCUBE_POSTGRESQL_USER
sudo sudo -u postgres createdb --owner $ROUNDCUBE_POSTGRESQL_USER $ROUNDCUBE_POSTGRESQL_DB
# NOTE: We have to wrap the username in quotes, because SQL will downcase everything outside of quotes.
sudo sudo -u postgres sh -c "psql $ROUNDCUBE_POSTGRESQL_DB" <<EOF
  ALTER USER "$ROUNDCUBE_POSTGRESQL_USER" WITH ENCRYPTED PASSWORD '$ROUNDCUBE_POSTGRESQL_PASSWORD';
EOF
sudo sh -c 'cat >>/root/.pgpass' <<EOF
localhost:5432:$ROUNDCUBE_POSTGRESQL_DB:$ROUNDCUBE_POSTGRESQL_USER:$ROUNDCUBE_POSTGRESQL_PASSWORD
EOF

And then set up that particular site to use RoundCube.

# Configure the site to use RoundCube.
cd /var/www/webmail.boochtek.com
sudo mkdir {public,config,temp,logs}
sudo chown -R www-data:www-data .
(cd public; sudo ln -s ../{config,temp,logs} .)
sudo cp /usr/local/share/roundcube/$ROUNDCUBE_VERSION/config/* config/
sudo ln -s /usr/local/share/roundcube/$ROUNDCUBE_VERSION/config/.htaccess config/.htaccess
sudo ln -s /usr/local/share/roundcube/$ROUNDCUBE_VERSION/temp/.htaccess temp/.htaccess
sudo ln -s /usr/local/share/roundcube/$ROUNDCUBE_VERSION/logs/.htaccess logs/.htaccess
sudo ln -s /usr/local/share/roundcube/$ROUNDCUBE_VERSION/{.htaccess,index.php,installer,plugins,program,robots.txt,skins,SQL} public/

Configuration

Browse to http://webmail.boochtek.com/installer/.

  • Make sure all the requirements are met.
    • Try to enable as many of the optional items as well.
  • Click NEXT.
  • In General Configuration:
    • product_name = BoochTek Webmail
    • CHECK ip_check
    • CHECK Cache messages in local database
  • In Database Setup:
    • Database type = PgSQL
    • Database server = localhost
    • Database name = $ROUNDCUBE_POSTGRESQL_DB (from above)
    • Database user = $ROUNDCUBE_POSTGRESQL_USER (from above)
    • Database password = $ROUNDCUBE_POSTGRESQL_PASSWORD (from above)
  • In IMAP Settings:
    • default_host = ssl:/\/slashmail.org
    • port = 993 (for IMAPS)
    • username_domain = slashmail.org
    • CHECK auto_create_user (allows automatic use for any IMAP user on our system)
  • In SMTP Settings:
    • smtp_server = localhost
    • smtp_port = 25
    • smtp_user/smtp_pass = (blank)
  • In Display settings & user prefs:
    • pagesize = 12
    • UNCHECK prefer_html
    • CHECK preview_pane
    • draft_autosave = 3 min
  • Click on CREATE CONFIG button.
  • Save the 2 config files.
    • Save the files in /var/www/webmail.boochtek.com/config/ with names of main.inc.php and db.inc.php
  • Edit /var/www/webmail.boochtek.com/config/main.inc.php to change the imap_auth_type setting to LOGIN.
    • NOTE: This is likely only necessary for Slashmail.org access.
  • Hit the CONTINUE button.
  • The next page will test the config to see if everything is OK.
  • The DB Schema will show as NOT OK (Database not initialized)
  • Click on the Initialize database button.
  • Now the DB Schema should show as OK, along with DB Write and DB Time.
  • Next, skip down to the Test SMTP config section.
  • Enter a sender and recipient, then click the Send test email button.
  • The page should come back with SMTP send: OK.
  • Next, skip down to the Test IMAP config section.
  • Enter login info for an account on the IMAP server and click Check login.
  • The page should come back with IMAP connect: OK.

Don't leave the DB password world-readable:

sudo chmod 640 config/db.inc.php

Additional configuration can be done in the /var/www/webmail.craigbuchek.com/config/main.inc.php file.

Remove the link to the installation directory from our webmail instance:

sudo rm /var/www/webmail.boochtek.com/public/installer

Upgrading (OBSOLETE)

NOTE: It is highly recommended to ensure that nobody is logged into the webmail system when upgrading.

First, make a backup of the current version, just in case.

cd /var/www/webmail.boochtek.com
sudo cp -a roundcubemail roundcubemail.backup-`date +'%Y%m%d'`

Since we're using Subversion to download the code, we can simply pull the latest revision. First, check the current revision info:

cd /var/www/webmail.boochtek.com
svn info

Then update to the latest revision:

cd /var/www/webmail.boochtek.com
sudo svn up
svn info

Check the config files, to add any new parameters:

cd /var/www/webmail.boochtek.com
diff -u roundcubemail/config/db.inc.php roundcubemail/config/db.inc.php.dist 
diff -u roundcubemail/config/main.inc.php roundcubemail/config/main.inc.php.dist 

Change anything necessary in the config files, then check the installation by browsing to /installer/.

Once everything checks out, remove the unnecessary files again:

cd /var/www/webmail.boochtek.com/public
sudo rm -rf installer/ README INSTALL UPGRADING LICENSE CHANGELOG

Usage

Browse to http://webmail.boochtek.com/. Log in with credentials against the IMAP(S) server.

TODO

Do we want to log to syslog? That would make log rotation work better, but I'm not sure we need to log at all, except when troubleshooting.

There are a lot of plugins we'd like to install and use.

build/webmail.txt · Last modified: 2014/09/03 14:09 by Admin