I have written/highly modified a perl script to take piped in emails and insert them into a MySQL database. I accomplish this by having my MTA pipe them to this script. You can download the script from this Github Repo, or you can download it directly from here.
This script requires that you have Perl installed with the following Modules:
- DATABASE The name of the Schema/Database
- SERVER The host of the MySQL Server. ex: localhost, 192.168.0.10, etc
- USER The user of the MySQL database
- PASSWORD The password of the MySQL user