SquirrelMail Multidomain Login with Postfix

So, imagine you have a Postfix installation which has virtual domains configured and then you want to use SquirrelMail to provide webmail access to those domains. If you check out the default SquirrelMail installation you'll see it has no multi-domains option by default.

Recently, I needed to provide such a configuration so I started googling around for information. I eventually found how to configure SquirrelMail for that, but it wasn't that easy so I thought I'd just compile all the info here if anyone needs to do something similar.

First of all, be sure to have your virtual domains correctly configured, that is, by using the Virtual Domains Howto. In particular, by following the linked how-to, you'll be creating a file which will hold the virtual domains, e.g. /etc/postfix/virtual, in my case, which you'll later process with postmap to create a hash table, for example.

Then, and this is the main trick of the show, you'll need the Login Manager plugin for SquirrelMail (this plugin is not available in the Debian package manager at the time of this writing, but requires the squirrelmail-compatibility package). Despite the last date of modification, which seems old, the plugin works perfectly with recent SquirrelMail versions (I' using it on version 1.4.20) and by reading the feature list you can guess it's a very powerful plugin (I've just started playing around with it and I already think all this functionality should be incorporated into SquirrelMail itself).

After fetching the package and following the instructions in the docs/INSTALL file, the only other thing I needed to set up for the Postfix virtual stuff to work was adding the following  line to the plugin configuration file:

[code lang="php"]
$sendmailVirtualUserTable = '/etc/postfix/virtual';
[/code]

By using this line, and a couple of default options that are set in the plugin, SquirrelMail will guess the domain of the user from the URL and use the virtual user table to map the e-mail to an account in the server for password validation. This means you can, for example, log in with the account name only (without the @domain part) in which case the domain will be appended.

You should play around with the rest of the options of this plugin which offers a great deal of flexibility for every domain you host (as you can use per-domain configurations).