It depends on what you mean exactly with database.
If you want to store mail into a (real) RDBMS you could indeed use dbmail. In don't really see the advantage in day to day use of email of a RDBMS, though.
If you mean that you want to store mail on a server for several users you may not want to use a POP mail server. Instead, you want to use an IMAP server. IMAP keeps the mail incl. subfolder structure and read/unread info on the server, allowing the users to view their mail from an arbitrary mail client that knows IMAP, including webmail applications.
Standard IMAP mail servers for Ubuntu are Courier, Cyrus and Dovecot. To store login credentials for your users openLDAP would be a good choice. The complete picture would probably involve :
- a MTA like Postfix or Exim
- a IMAP server like Courier, Dovecot or Cyrus
- a dbase like MySQL or OpenLDAP for login credentials/user info.
- several mail filter utilities to wheat out spam, like clamav, spamassassin, greylistd and razor.
- maybe a webmail application like squirrelmail or horde.
You could such a setup even if you wanted to store the mail in a database. You could export email (in the background) to a (very) fast database like CouchDB and do al the analyses from their. A chapter in 'Mining the Social Web' by O'Reilly seals with a scenario like that, BTW.