tags:

views:

675

answers:

2

I'm looking to do various processing of email - eg. inspect the headers, and if they meet some criteria (look like spam), drop the connection, or inspect the recipient list and perform special filtering.

Looks like Python's smtpd library provides a nice and simple interface for processing the received email.

To deal with the message before it's fully processed (eg. to drop the message in case the headers look like spam), should I be using handle_connect? Are the internal APIs (other than process_message) documented somewhere? Example code anywhere?

Also, has anyone used smtpd in production? Any thoughts on reliability, etc?

Regarding Twisted: I've attempted to embrace Twisted several times and quite like the deferred model, but it's a bit too complex for my current taste. I'll give it another look, but for now I'm more interested in non-Twisted implementations.

+4  A: 

You may want to look at the twisted implementation as that will give you access to the full range of interaction with the client. I believe (though I have never used it in production) that twisted can be trusted in a production environment.

Andrew Cox
A: 

Another approach: use Postfix for receiving email and write a policy script in Python.

ΤΖΩΤΖΙΟΥ