Using python with postfix pipe.

08.06.2008 13:56

posted by: Benjamin Smith

Posted Under: , ,

Dear Lazyweb,

I was wondering if anyone here had experience with using a postfix pipe to a python program for processing mails. Most of my background in mail processing is with qmail, Perl and procmail.

From what I can tell there appears to be a ‘pipe’ command that I could use in an alias to point it at my python program, then use the ‘email.FeedParser’ class to keep it from blocking. For now I’m parsing mails from the maildir via the ‘email.Parser’ class, then moving them around. It would be very nice to process them as they come in. This would eliminate overhead from firing up python whenever I want to parse messages and make my process somewhat real time.

Any ideas/snippets/caveats are greatly appreciated!

P.S. I’m doing this in python to hook into byteflow, the django app powering this site.

5 comments | 0 pingbacks
Add post to: Delicious Reddit Slashdot Digg Technorati Google
Comment

Comments

Benjamin Smith 8.06.2008 15:09

Eh…after some quick hackin’ I discovered its quite simple to accomplish what I’m looking for. Still, any other suggestions or comments are welcome!

reply
Matt 8.06.2008 21:17

I was working on something simlar a few weeks ago:

http://blog.tplus1.com/index.php/2008/05/21/frustration-with-postfix-and-sending-email-to-a-script

So, what did you come up with? I’m not thrilled about my solution.

Anyhow, I like the giant font in this text area!

reply
Benjamin Smith 9.06.2008 18:58

Mine too was an ugly hack and I feel dirty even mentioning bits of it.. Basically hacked it together with man 8 pipe and slurping up stdin.

reply
robataka 10.06.2008 8:20

Benjamin, probably not very helpful suggestion, but have you looked at what Mailman does?

reply
Benjamin Smith 10.06.2008 8:39

Actually, that’s where I got the idea for what I did!

reply

Comment form for «Using python with postfix pipe.»

Required. 30 chars of fewer.

Required.

captcha image Please, enter symbols, which you see on the image