If an email sent on [email protected], I want to put the contents of the email in a database, but how may realize it? I use postfix to MTA.
                +3 
                A: 
                
                
              
            If you definitely must, write a program to process the input (say /usr/bin/your_program) and place this in /etc/aliases:
intended-local-address: "|/usr/bin/your_program"
                  codehead
                   2009-05-15 01:59:05
                
              
                +1 
                A: 
                
                
              
            I have used fetchmail. If You configure it right, it can make a blocking call to a remote IMAP server (it will hang until a mail is received, how cool is that, no active polling!). It handles many kinds of mail protocols. It puts the email with it's headers into a program of Your choice (I used python and it's builtin mail parsing libary).
I must say I am proud of this solution, as it was relatively easy to setup and very effective on the end.
Few more things worth noting:
- The connection times out or resets eventually (after several hours, sometimes several weeks). I suspect that the IMAP server was being restarted.
- Don't try to parse the email by Yourself. I gave up after debugging the 5th way of sending email body and then used the existing lib.
- After the poll finishes, do a sleep 5 or something before You poll again. My mail program once felt into an infinite loop with another one and the sleep 5 saved me.
                  Reef
                   2009-05-16 08:53:47