Dovecot have a plugin, called notify You can use as a base and develop your plugin to write the itens that you want in the database.
in dovecot source, see in src/plugins/notify 2010/11/17 Oliver Berse <m...@oliver-berse.de> > I'm a newbie at Dovecot. For a company groupware I need a kind of a > history function for mails to see which user sent which mail to whom / got > which mail from whom. So I have to get the message ID of in- and outgoing > mails (and write related data to a mysql database). My first idea was to > monitor the log file with a daemon and search for strings like > "deliver(x...@y.z): 2010-11-15 17:34:56 Info: > msgid=<aanlktikorguieg2kguw2glmuld4tx-bpst4yhubuh...@a.b>". I'm not sure > if this is the right approach. Does anyone know a better solution with > Dovecot? > > thanks, > Oliver >