[BangPypers] procmail and python

Noufal Ibrahim noufal at gmail.com
Wed Dec 21 09:43:09 CET 2011


Amit Sethi <amit.pureenergy at gmail.com> writes:

> Has anybody here used some kind of python script with procmail . I
> want to set up a script that looks at a certain words in a mail and
> forwards it to users. However I am not able to understand how can I
> read the message in python script.
>
> The documentation suggests something like this should send the body
> and header to the stdin of my  script but what I get some gibbresh
> text.
>
> :0 bh
> | /usr/bin/python /home/amit/work/scripts/respond.py
>
> Any ideas ??

Ah the smell of old school UNIX at lunchtime. Most of my procmail
fu has evaporated but I'll try. 

I'm not sure if procmail allows the "interpreter filename" spec. You'll
probably have to make your .py script executable and then use a #! on
top. Touch a file in /tmp inside your script to make sure that it's
running when mails are received. Try that.

But why involve Python in this at all? You can use something like

:0 B
word1|word2|word3
! forward at example.com

to do the actual pattern matching and forwarding can't you?


-- 
~noufal
http://nibrahim.net.in

Of course I can keep secrets. It's the people I tell them to that can't keep them. -Anthony Haden-Guest


More information about the BangPypers mailing list