Skip to content


Roundcube for your Debian Squeeze Mail Server

I am a big fan of the workaround.org “ISPmail tutorial” for setting up mail servers. It works pretty good and is usually pretty detailed and to be honest, I’ve been using it for years to configure my mail servers under Debian Linux. After migrating to squeeze the first time, I just used the tutorials “Migrating from the Lenny” section to update my server.

I’ve always loved roundcube as well and even in the early days found myself stopping the tutorial and configuring my own copy of roundcube. The new tutorial actually makes mention of roundcube so I was excited when I got the opportunity to configure a new mail server. The only disheartening thing was that the mail server tutorial for squeeze isn’t finished to the point where it talks about roundcube configuration. I’ve set it up many times so I thought I’d try to use the generic debian apt packages and go ahead and document my steps along the way. Here we go…

Step one:
You need a working mail server preferably using the workaround.org mail tutorial.

Step two:
lets go ahead and install the roundcube packages we need

1
apt-get install roundcube roundcube-mysql

As you go through go ahed and let it configure the roundcube package to connect to mysql. It will create a username and random password for this connection. The information is stored in /etc/roundcube/debian-db.php if you need to change something later.

Step three – configuring the apache side:
at first glance I was a little frightened by how they had made the roundcube package interface in with Apache2. The generic debian /etc/apache2/conf.d/roundcube config is setup to work as a wildcard alias. This means you can access roundcube from any active apache site by going to /roundcube or even configure it to /webmail or something. I absolutely hate this config because it interferes with default structure of websites (Example, if a client already had a /webmail folder it could get confusing). In the past I’ve just downloaded roundcube and installed it in the default html folder. This allows me to point all sites on the mail server to the default document root and serve up mail to all of them. This time I wanted a little more custom config.

Step three point one:
Debian links and installs roundcube in a way that is pretty nice. Configs are in /etc/roundcube etc. but all the packages tie back together with apache +FollowSymLinks and are stored in /var/lib/roundcube. This gave me the idea for my current configuration mixed with the default. First all my users are on the same IP for the mail server and I just use DNS to point probably like most of you do. I decided that I wanted all my customers that came to mail. or webmail. to be served up the roundcube files while still leaving the other sites (even the default mail server page to point elsewhere). I began by creating a file in /etc/apache2/sites-available that looked very similar to the one used by the default debian /etc/apache2/conf.d/roundcube file.

/etc/apache2/sites-available/webmail

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<VirtualHost 10.0.18.1:80>
        ServerAdmin chrispierce@gmail.com
        ServerName mail.somehost.com
        ServerAlias mail.* webmail.*
        DocumentRoot /var/lib/roundcube
        Alias /program/js/tiny_mce/ /usr/share/tinymce/www/
        <Directory /var/lib/roundcube/>
                Options +FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
        <Directory /var/lib/roundcube/config>
                Options -FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/lib/roundcube/temp>
                Options -FollowSymLinks
                AllowOverride None
                Order allow,deny
                Deny from all
        </Directory>
        <Directory /var/lib/roundcube/logs>
                Options -FollowSymLinks
                AllowOverride None
                Order allow,deny
                Deny from all
        </Directory>
        <Directory /usr/share/tinymce/www/>
                Options Indexes MultiViews FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

As you can see there are only a few stray lines that need explaining. First I point the default ServerName to the mail host I have setup. Then I use wildcards in my ServerAlias to point all sites that reverse to my IP that have mail or webmail in them to go to the same place. I altered the tiny_mce code just a tad in the Alias just to make sure it pointed to the right spot in roundcube (i’m not using /roundcube in my url). The rest still holds true to the apache2 generic config found in /etc/apache2/conf.d

Step three point two:
Next we need to do 3 things. Enable the apache configuration for our new site (webmail):

1
a2ensite webmail

This links the site into /etc/apache2/sites-enabled
Secondly we disable the old configuration so that roundcube isn’t loaded when we goto /roundcube or /webmail on a page by removing the file in conf.d.

1
rm /etc/apache2/conf.d/roundcube

*Note if you ever want to put this back you can just create a symbolic link back to /etc/roundcube/apache.conf named roundcube in /etc/apache2/conf.d

Last we enable the changes by reloading the apache2 service.

1
/etc/init.d/apache2 reload

We should now be able to test the configuration by going to webmail.somedomain.com and seeing if we get the default roundcube page.

Step four – Making a few changes to the roundcube configuration
At this point you can install a different skin or make any configuration changes you’d like. The one thing I did notice is the default install has a problem moving mail to trash because it doesn’t create the default trash folder for you. There were a few other things I’ll note too. Let us now take a look inside the /etc/roundcube/main.inc.php file and make a few small changes.

First the default host should be changed to the domain or ip you use to check your mail. Note my mail server uses SSL so I have configured the site as such but ssl:// is not a required thing (unless you like security).

1
$rcmail_config['default_host'] = 'ssl://10.0.18.1';

Since I’m using SSL I also had to make the following change.

1
$rcmail_config['default_port'] = 993;

I also don’t like showing the drop down for the mail server as an option so as you can see above I removed the array() enclosing the code for the server. This hard codes the mail server and drops the option to show what the mail server is on the login page. I think this looks overall more clean than showing what the mail server connection is, and since I only have one mail server I don’t really see the point of showing the world what it is.

Next I go ahead and configure sendmail to send out of my localhost using the following configs.

1
2
3
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';

This ensures the mail sent out is actually sent from the specific user using the local mail server. If you are hosting roundcube on a different server than the mailserver you might need to adjust this to fit.

I went ahead and made the change to the $rcmail_config[‘product_name’] and just did ‘Webmail’ instead of ‘Roundcube Webmail’. This comes from me not helping the bad guys with any more information than they need by default. If they don’t recognize the client, then I don’t see a point in spelling it out for them.

By default my structure of folders is INBOX, Drafts, Sent Mail, Spam, and Trash so I make the changes to those accordingly for box *_mbox and default_imap_folders.

Lastly to fix the problem I mentioned above we need to create these default folders when We login using the following.

1
$rcmail_config['create_default_folders'] = TRUE;

You can also protect these folders from being removed if you’d like by using protect_default-folders set to TRUE. I like this as it doesn’t have to recreate the folders each time. I bumped my session time up to 45 minutes just to give slow webmail users the ability to not get logged out when typing a lengthy email. Aside from this you can change the settings as you see.

Next I always change the default “username” locale to “Email” as I think it makes more sense to show it as email since you have to type the entire address and not just the default username of the mail user to get logged in (unless you configure more which I won’t get into here). We do this by editing the setting in /usr/share/roundcube/program/localization/en_US specifically in labels.inc

1
$labels['username'] = 'Email';

I go ahead and change my junk mailbox label to say Spam and my sent folder to say Sent Mail just to keep things conform. At this point you can install any skin you’d like via /var/lib/roundcube/skins and any plugins you want to use via /var/lib/roundcube/plugins. I hope this helps someone and please don’t hesitate to ask questions if you have them.

Posted in Debian Linux, Linux, Mail Server, PHP, Webmail.

Tagged with , , , , , , .