Software Sqwebmail is an excellent webmail system for Maildir-based mail systems, written by Sam Varshavchick. The sqwebmail homepage may be found here. One useful feature of the program is the ability to host mail for several different virtual mail domains. Typically, the way this operates is that a login name includes the domain (e.g. I would log in as "mml@mupsych.org" and sqwebmail will use @mupsych.org as my outgoing mail domain). Credentials are checked in a user database that can handle authentication and points sqwebmail to the user's Maildir. When using sqwebmail in single-domain mode, logins do not include a domain (e.g. I could log in as "mml") and outgoing mail is suffixed either with the hostname of the machine running sqwebmail, or an alternative specified in a configuration file.
These two modes of operation are sufficient for most purposes, but annoying for situations in which all users of a multi-domain setup have (and wish to use) system accounts for login. Several virtual hosts (websites) may run under a single Apache server, but if they all contain a URL pointing to the same copy of sqwebmail, all outgoing mail will appear to have emanated from a single domain, namely the one specified in the sqwebmail configuration or, in its absence, the hostname of the server. There are only two solutions to this problem: (a) use the full multi-domain mode, and ensure that every login name contains a domain part (i.e. do not allow users to use their system accounts), or (b) have a separate installation of sqwebmail for every virtual host, thereby allowing the mail domain to be set correctly for each in the configuration file. My patch was born because I like neither of these options.
The patch is a simple addition to sqwebmail that allows the outgoing mail domain to be set in an environment variable, namely VHOST_MAILDOMAIN. In conjunction with Apache's mod_env, this allows the domain to be set on a per-vhost basis from within the Apache configuration. For example, the snippet of Apache configuration below ensures that if sqwebmail is invoked using a URL from within www.scribblin.gs and I log in to it using my system username ("mml"), outgoing mail will appear to emanate from scribblin.gs:
<VirtualHost 192.168.1.1> ServerName www.scribblin.gs ... [irrelevant details snipped] ... ScriptAlias /sqwebmail/ /opt/sqwebmail/cgi-bin/ SetEnv VHOST_MAILDOMAIN scribblin.gs </VirtualHost>
There were substantial changes made in sqwebmail 3.6.2 (which corresponds to the full Courier package 0.44.1). Thus, there are two versions of this patch. For versions of sqwebmail released subsequent to 3.6.2 (and courier packages released after 0.44.1), use the following procedure:
Note: this patch was created against the Debian package of Courier 0.45.6, but has been tested against the upstream sources.
For earlier versions of sqwebmail, follow the same procedure, but download the 3.3.4 patch and type "patch -i sqwebmail-auth-c-3.3.4.diff. As the name suggests, this patch was written for sqwebmail v3.3.4. However, it may well work with other versions.
This patch is released into the Public Domain.