Installing necessary Debian packages

By now your Debian Squeeze server should be installed correctly. Now it's time to install the necessary Debian packages to make it an actual mail server.

To get a clean system with all security updates installed you may want to run:

apt-get update

apt-get upgrade

Debian Squeeze does not install the SSH server by default. So to spare you an extra walk to the server room I suggest:

apt-get install ssh

Then let's install Postfix with MySQL backend support:

apt-get install postfix postfix-mysql

When you get asked for the mail server configuration type please choose "Internet site". Enter your own mail server name (the fully qualified domain name).

As by default Debian installs exim as a mail service you should remove its remains:

apt-get --purge remove 'exim4*'

You also need a MySQL server:

apt-get install mysql-server

Note: You can run MySQL server on the same system as your actual mail service - but don't have to. The mail server can communicate with the MySQL server via TCP networking. Maybe you even have a MySQL server in your network already that you can use.

During the installation you will get asked for the password of a newly created "root" user. This is not your system's "root" login but a special administrative user used to access the MySQL server. Choose a secure password you want and write it down. And another warning: during the installation a MySQL user account called "debian-sys-maint" will be created with a random password. The password is stored in the /etc/mysql/debian.cnf file. Do not touch this file or change the user's password in the database or you won't be able to stop or start the MySQL service any more.

You will want to offer POP3 and IMAP services to your users so you need to install Dovecot's services:

apt-get install dovecot-pop3d dovecot-imapd

If you intend to offer a webmail service I can recommend the Roundcube package. Previous versions of the tutorial recommended Squirrelmail but honestly Roundcube is way more comfortable. Type:

apt-get install roundcube

This will also install an Apache server and PHP packages. You will get asked if you want to maintain the RoundCube package using "dbconfig-common". Basically this means that Debian will set up the database for you and in future releases upgrade the database. I suggest you say "Yes" here. The database type is "MySQL". When asked for the "database's administrative user's password" enter the password you entered for the MySQL "root" user when you installed the MySQL server. Then you will have to think of a safe password that RoundCube will use to access its database and enter that twice.

If you believe you are not a MySQL ninja on the command line then I suggest you install the PHPMyAdmin software which allows you to manage your MySQL database in the web browser:

apt-get install phpmyadmin

Again you are asked if you want to manage the phpmyadmin database using "dbconfig-common". Answer with "yes", enter the MySQL "root" user's password and think of a new password used for PHPMyAdmin to connect to its database. As a web server to be used select "apache2".

And finally the console-based mutt email client lets you read mail from mailboxes directly from the hard disk. It will be helpful for testing the configuration. And it's even a very powerful IMAP email if you like using the console. Maybe you'll start to like it, too. You should install it at least for testing:

apt-get install mutt

Now all basic packages are installed and it's time to prepare the database in the next chapter.

16 Comments

RoundCube - for anyone interested.

OK, first a disclaimer.

I was interested to find out how RoundCube integrates with Debian Squeeze, Postfix and Dovecot. Please be clear, I'm a novice email server admin and every little bit I know, comes by courtesy of Christoph right here. This post is purely for information, in the hope it may help others. I'm sure Christoph when time allows will write a more comprehensive account of how RoundCube should be installed. I have no idea whether this procedure introduces security vulnerabilities, so please take care. This should not be used on a production server, until it has been verified as being safe by my peers.

I found a lot of information about files to be edited, some of it quite complex and frankly, difficult to understand. Much of that information was out of date. The end result, was that always I ended up with a broken RoundCube in one form or another.

However, with the above warning firmly in your minds, here's what worked for me.

Install:

roundcube

roundcube-core

roundcube-mysql

php-mdb2-driver-mysql

I also noticed, roundcube-sqlite is installed and that may have happened as a dependency while installing the other packages. I really don't know. All I can tell you is, it's installed on my test server.

Once everything is installed, run:

dpkg-reconfigure roundcube

Simply enter the relevant details the reconfigure application asks for.

For me, that was it!

I could then access RoundCube from a web browser on my local network, logging in with one of the database names and passwords and have successfully sent and received email via RoundCube.

Hope that helps.

Further information.

First, on the subject of dpkg-reconfigure roundcube; if that doesn't work, try;

dpkg-reconfigure roundcube-core

Since my last post on this subject, further testing has revealed a unwanted trait. Namely, RoundCube appends the server address to the senders address, when using email scripts on websites.  For example:

Sender user@mail.example.org, original_sender@anywhere.com

(the second being the true sender).

A further issue is it's refusal to allow a user to delete email from their own inbox.

When using conventional email clients such as Thunderbird, these issues do not appear, so it seems, Postfix, Dovecot and AMaVIS are in the clear.

As yet, I haven't found satisfactory solutions, so if anyone else has experienced these problems and has answers, I'd be happy to hear from you.

Otherwise, it may be back to SquirrelMail, which in many ways would be a shame, as RoundCube is undoubtedly attractive.

and yet more.

The problem with not being able to delete files, was a configuration issue in RoundCube.

Go to:

/var/lib/roundcube/config

and use your favourite editor to view line 204 and edit line 205 in "main.inc.php"

You will see;

 

// automatically create the above listed default folders on login

$rcmail_config['create_default_folders'] = FALSE;

 

Change "FALSE" to "TRUE" followed by the semi-colon and all will be well next time you login.

It seems there is an issue with RoundCube not being able to delete emails due to no "Delete" box being available by default. Enabling the above line, will create the required boxes automatically on login.

More info

The issue:

Sender user@mail.example.org, original_sender@anywhere.com

is partly resolved.

It suddenly dawned on me, that the from address will always be from the sending server. This is clearly to try and authenticate the source of the message to help combat spam.

I've managed to get consistancy in regards to changing "mail.example.org" to "example.org".

The method is to change a parameter in /etc/postfix/main.cf file.

Find the line myorigin = /etc/mailname

and change it to:

myorigin = $mydomain

This will deliver emails with the from address set to:

[name of whoever sent the email]@[your server domain name]

(for example; user@example.org)

in other words, it drops the host name out of the address.

The issue of muliple addresses continues, but I think that's possiby a function of the website script, rather than any fault of the server and hopefully I will be able to ask the developer of the script if that is likely and whether a resolution is possible.

In the interests of clarity, what I mean by this is; if the website form asks for a user name and someone entered John Doe in that field; the resultant email would end up with addresses:

john@example.org, doe@example.org.

If anyone has had experience of this and knows an answer, I'd be most grateful for a comment.

Address problem.

To bring this to a conclusion, the dual address problem I was experiencing was in fact a website script problem and nothing to do with the email server components.

I've made a temporary change to the script and it works satisfactory. But I'll need to investigate a more permanent fix for the future.

So the conclusion is, for me, RoundCube is working well, and the only changes I've made are as described above. But remember, I've no idea whether I've now introduced any security vulnerabilities, so I await with interest at Christoph's conclusions on the matter, when he has finished his evaluation.

Roundcube Bug Alert

You should make a note that on a vanilla debian squeeze install if you follow these instructions roundcube will not work as described above out of the box due to a package dependency error.

The following should fix your problem:

apt-get install  php-mdb2-driver-mysql
apache2ctl restart

I did not install myphpadmin because of how many bugs/vunerabilities it has on an ongoing basis maybe this was the reason php-mdb2-driver-mysql didn't get installed on my configuration. But if you are like me and administer mysql from commandline you wouldn't have installed it anyways.

Roundcube: Instant log out

I was instantly logged off by roundcube after login. Roundcube error log said:

[04-Jul-2011 11:39:26] PHP Deprecated:  Assigning the return value of new by reference is deprecated in /usr/share/php/MDB2.php on line 393
[04-Jul-2011 11:39:26] PHP Deprecated:  Assigning the return value of new by reference is deprecated in /usr/share/php/MDB2.php on line 2647
 

Adding the following to /etc/php5/apache2/php.ini solved the problem:
suhosin.session.encrypt = 0

Above fix found here:
https://bugs.launchpad.net/ubuntu/+source/roundcube/+bug/625303


Thank you for the tutorial(s),
Tobias

webmail

I'm not surprised you cannot see Roundcube.

On a standard Debian install, it defaults to:

/var/lib/roundcube

Have you set up your web server to point to that document route?

Alias

Alias /roundcube/program/js/tiny_mce/ /usr/share/tinymce/www/
Alias /roundcube /var/lib/roundcube

ok now but on the roundcube page I got

DATABASE ERROR: CONNECTION FAILED!

Internet site

Hello, if you type your qualified domain in the config, when you install postfix, after mail.log tells:

warning: do not list domain xxxxxxx.net in BOTH mydestination and virtual_mailbox_domains

Thank you for the tutorial

dovecot & mysql

I ran into an error later in the process that seemed to be fixed by
sudo apt-get install dovecot-mysql
running on Ubuntu server 12.04