Parand
Parand

Reputation: 106350

Python: smtpd (or alternative) for production mail receiving?

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.

Upvotes: 3

Views: 1784

Answers (2)

tzot
tzot

Reputation: 95991

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

Upvotes: 1

Andrew Cox
Andrew Cox

Reputation: 10988

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.

Upvotes: 5

Related Questions