qmail/MySQL - contributed work
There are several ways in which my patches could be extended. I have either not needed to, not had time to or simply not wanted to do this work. If anyone has expanded (or fixed) these patches in any way, I will be happy to host them up.
Bad address patch (Stephen Hawkins)
Obsolete. Now included in 1.1.13 and above.
Stephen Hawkins sends a patch which allows qmail to generate a 550 bad address error message when mail for email@example.com arrives where domain.tld is a domain in the virtual table but user is not a valid value for virtual_username and no catchall exists.
Without this patch, my MySQL code would bounce the message with the infamous "Although I'm listed as a best preference MX or A for that host, it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)." error. Stephen reports that this caused the Postini anti-spam software his site uses to barf. Let's harken at the equine's buccal cavity:
The server has almost 400 virtual domains, with a total of 2833 email accounts currently, all running with out a hitch.
Well, that is until I noticed some odd looping going on with bogus email addresses. Now, this appears to only be because of a spam filtering service we offer to our virtual domain customers. But our spam filtering service (Postini) requires a 550 <bad address> error message to be generated from our smtp server, in the case a bogus rcpt to: query. Because of this, some of our customers (the "email admins" for these filtered domains) were starting to receive over 50+ looping error messages each day.
Since qmail doesn't seem to support this behaviour by default, and since I couldn't find a patch for the system you've written, I had to hack in the functionality to your own work. I've generated a patch based off my original source tree (qmail-1.03 + qmail-mysql-1.1.7.patch) and the modified version of the same. But, actually only minor changes were needed, and the following files where changed: mysql_queries.h, qmail-smtpd.c, rcpthosts_mysql.c.
One downside, I guess, is that it only checks the mysql records for valid users/domains... It does not look at the regular config files....
I'm not sure if may others will find this patch useful/interesting, but I figured I should share it with you and everyone else...
Once again, here is Stephen's patch.
Courier IMAP (Condor)
Condor reports that Courier 1.4 and above supports my database schema without his patch. The details are preserved for reference:
The following is unsupported by me. I knocked up a quick patch to Courier IMAP to allow it to authenticate from the same database as my patched qmail-pop3d uses. This way you can mix and match different password types in your database as well as getting MySQL scrambled password support.
Warning! This is a quick and dirty HACK. I do not fully understand IMAP and I probably forgot something important. But it appears to work for me.
First, apply this patch to your Courier IMAP source tree (tested on 126.96.36.199).
patch < courier-imap-mysql-1.2.0.patch
Build Courier IMAP.
./configure --whatever && make all install
Edit your /etc/authmysqlrc (or wherever it is; you may need to run configure with the --sysconfdir=/etc to have it live there).
The following assumes you use the default field names in the database.
- Change "MYSQL_LOGIN_FIELD id" to "MYSQL_LOGIN_FIELD username"
- Comment out "MYSQL_CRYPT_PWFIELD" and "MYSQL_CLEAR_PWFIELD"
- Add: "MYSQL_PWFIELD password"
- Add: "MYSQL_PWTYPEFIELD password_type"
Assuming you installed Courier IMAP into /opt/courier, start it up with something like:
#!/bin/sh exec 2>&1 tcpserver -v 0 143 \ /opt/courier/sbin/imaplogin \ /opt/courier/libexec/authlib/authmysql \ /opt/courier/bin/imapd .
Using Courier IMAP on Debian Linux (Gavin Hamill)
Obsolete. Debian now includes stuff to do this out of the box.
Everything from this point on was submitted by Gavin Hamill, a regular correspondant. His instructions assume you DIDN'T patch the source as described above: you're going to apt-get the package!
Before I clear the stage, I'll mention that the Debian package he sent is available here.
And now over to Mr Hamill.
Hiya... not sure if you're interested in putting this on the files section, but this is a Debian package for courier-imap to work with your patches :)
It was annoying because the standard courier-imap mysql module with Debian would work perfectly out of the box, except it uses 'id' where you use 'username' :)
Basic instructions for Debian 'testing' or 'unstable' dists - I can't speak for 'stable'...
apt-get install courier-imap
This will install courier-base as well.
dpkg -i /path/to/where/you/downloaded/courier-authmysql_0.32.0-3_i386.deb
Edit /etc/courier/imapd and change the AUTHMODULES line to say
Now ONLY the MySQL database can be used to gain mail access...
It doesn't seem to support MySQL-style passwords. Finally,
And that should be it =)