I was thinking about Qmail-Vmailmgr-CourierIMAP-SquirrelMail... but have
not set it up yet. You can see a how-to on doing all of it at: http://mricon.com/SM/guide/
I know this is missing the DB part of your pie, but maybe someone else
will have some insight on that part. There are some resources off of http://www.qmail.org/.
I did see these, which is at least linking qmail and postgresql:
Mail2DB -- Store
incoming mail in a PostgreSQL database. Mail2DB is suitable for putting
in a .qmail/.forward file and will archive e-mail to a SQL database. Currently,
there is only the storage component. This was written because somone on
a LUG list expressed interest in such a system, but he only knew PHP (which
isn't an ideal language for calling from a .qmail file 😉. Hopefully a
user interface will be forthcoming.
Jesse Sweetland has added Postgres support to his checkpassword and
qmail-getpw replacements. He calls the package sql-xpw.
These differ from Takeshi's code because his is a patch to qmail and this
code is not.
My mail system is qmail(Maildir) + qmailpopd + UW IMAP + Postgres. Go
to freshmeat.org and search for pam-pgsql. It's really simple, you
need a table (I suggest restricting access to root only) with a
loginname, password and expiry date.