I want to connect to receive email and attachments

If the email is sent to XXXX@YYYY.ZZZ , I want to put its content into the database, but how do I implement it? I am using postfix for MTA.

+1


a source to share


2 answers


If you definitely need to write a program to handle input (say / usr / bin / your_program) and put it in / etc / aliases:



intended-local-address: "|/usr/bin/your_program"

      

+3


a source


I have used fetchmail . If you set it up correctly, it can make a blocking call on the remote IMAP server (it will hang until mail is received, how cool it is, without actively polling!). It handles many kinds of mail protocols. It puts the email with headers into a program of your choice (I used python and it has built-in mail parse parsing).

I have to say that I am proud of this solution as it was relatively easy to set up and very efficient in the end.



Few deserve attention:

  • The connection time is disconnected or reset (after a few hours, sometimes several weeks). I suspect the IMAP server is restarting.
  • Don't try to analyze email yourself. I gave up after debugging the 5th way to send email body and then using the existing lib.
  • After completing the interview, do dream 5 or something else before you interview again. My mail program once felt an endless loop with another, and sleep 5 saved me.
+1


a source







All Articles