Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm developing a web application that requires that a registered username be able to receive emails to:

<some-username>@<my-web-app>.com

I need a way to be able to process the email with Python once the system has verified the address is in the system.

Assuming you are using Postfix, how can you add a hook for Python to do some post processing, once an email is received?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Create a pipe alias in the aliases file (e.g. /etc/aliases).

some-username@my-web-app.com |/path/to/somescript.py

And then use the normal Python stdlib modules to tear the message apart.

If you need multiple addresses to point to it then have them all aliased to the newly-created alias.

share|improve this answer
    
I definitely need to do some more research on mail servers - I completely underestimated their complexity. I'll assume your solution is correct though, and will follow up once I reached that point, thanks! –  NFicano Nov 27 '10 at 6:13
add comment

See this page that contains useful information for writing milters in Python.

share|improve this answer
1  
milters, as much as I love them, are probably not the right tool for this job, as he's looking to accept the messages, not just filter them before delivery. I'd personally probably use either a .forward file or make it a postfix transport. –  Sean Reifschneider Nov 27 '10 at 9:16
    
What he is looking for is definitely doable with Python in a milter context. I am doing similar stuff with MIMEDefang, which I did not recommend because he wants a Python interface. –  adamo Nov 27 '10 at 13:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.