Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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
up vote 6 down vote accepted

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

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

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

share|improve this answer
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

Your Answer


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.