Dbmail is the name of a group of programs that enable the possibility
of storing and retrieving mail messages from a database. Currently
MySQL, PostgreSQL and SQLite can be used as database backends.

DBMail is made up of several components. A normal MTA (Postfix,
SendMail, QMail, Exim) is used for accepting messages. The MTA
hands the messages over to dbmail-smtp, using a pipe interface, or
dbmail-lmtpd, using LMTP (Local Mail Transport Protocol). These
programs take care of delivering the message into the database.
Messages can be retrieved from the database using dbmail-pop3d,
using the POP3 protocol, and dbmail-imapd, using the IMAP4Rev1
protocol.

The whole email is stored in the database. That includes attachments.
The DBMail programs do not have to touch the filesystem to retrieve
or insert emails. User information is also stored in the database,
so users do not need an account on the machines DBMail is running
on.

Homepage:
https://github.com/dbmail/dbmail
