well,
posibly be done with a cron script on a server set to excute everything in a directory (that the mail server passes the files to after reciving them) to a mysql script.
However.... there are a bunch of mail headers there in every email message that could cause some errors unless you are able to filter that out some how.
but honestly you would have to know the mysql command line commands to excute things correctly.