LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   [MTA] Best way to get the mail spool to a MySQL database (https://www.linuxquestions.org/questions/linux-server-73/%5Bmta%5D-best-way-to-get-the-mail-spool-to-a-mysql-database-928258/)

sanjioh 02-08-2012 03:03 AM

[MTA] Best way to get the mail spool to a MySQL database
 
Hi,

I need to setup a mail server that does a particular thing: it receives mail (from user SMTP submission) and, instead of deliver or relay, "does something" that ends up in having the mail (body + headers + attachments) in a mysql table.
The ideal thing would be some mta that keeps the mail spool directly on a database backend; knowing that this is generally unwanted because of performance and reliability issues (and thus, rightfully, never implemented), I'm trying to figure out a way to get the same result.
Note: strict realtime is NOT a requirement (I'm allowed to do some sort of processing between mail arriving and its insertion in the database).
After a couple of days of brainstorming, I came to a conclusion that relies on Postfix and on some coding: using the after-queue filtering capabilities of Postfix, I would first dump the mail (flat file) in a directory (with a slightly modified version of this bash script: http://www.postfix.org/FILTER_README.html#simple_filter); then, using a cronjob scheduled every, let's say, 5 minutes, invoke some (php? ruby? perl?) script that does the batch import task "out of band" and removes the dump file.
I think that this "decouple" thing should give robustness to the whole process, providing small and single-task scripts for dump and import phases; it should be the "unix way" of doing things right :)

What do you think? Please correct me if I'm wrong in something. Thank you!


All times are GMT -5. The time now is 05:01 PM.