AndyB wrote:
> This sounds like exactly what I need to do. However my Unix-fu isn't
> up to coping with the sentence 'We have an alias set up in postfix
> that sends the e-mail to our script via a pipe.'... :(
>
> My naive assumption is that one could use something like poplib in the
> standard library to connect to a POP3 server and process incoming
> emails that way. Does that sound a sensible route to take?
>   
It does sound sensible, but a heck of a lot more complicated than
setting up an alias.

If you use postfix, all you need to do is add one line to your
/etc/aliases file and run newaliases. Here are the few lines in our
postfix aliases file:

    tick:           "|/git/tick/tickets/email_process.py /git comment"
    closed-ticket:  "|/git/tick/tickets/email_process.py /git closed"
    open-ticket:    "|/git/tick/tickets/email_process.py /git open"

Ours is a ticket system called tick. we have an 'email_process.py' that
takes two arguments- /git is a directory to prepend to the
PYTHONPATH.the last argument is the type of e-mail message we are
processing. We also have a ticket open handler, and a ticket close
handler, but we don't use them.

It seems like running a Python process constantly to check pop3 is more
overhead, and an additional service to run. If you are already running
postfix, an alias is a really simple and efficient way to get e-mail
messages processed on the fly as they are received. The disadvantage is
that each time a message is received, a python interpretor is loaded
into memory. If you will be handling more than 1 or two messages a
minute, I'd definitely go for the pop3 route, and have the python
process stay loaded in memory. It'd put a decent amount of load on the
mailserver to constantly check and download hundreds of messages all the
time, but my guess is that it might be less load than loading several
hundred instances of a python interpretor. It'd be interesting to test.


Jeff Anderson

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to