[Twisted-Python] Mail content filter: How to avoid SMTP client finishing sending message before SMTP server finishes receiving it?
jack.bates at gmail.com
Sat Dec 11 20:05:08 MST 2010
Struggling little bit to write a Postfix content filter  with Twisted
Mail. The content filter will eventually add a cookie to the "from"
address, identifying the address that the message was sent to
Here's my attempt so far 
The problem is that the SMTP client finishes sending the message before
the SMTP server finishes receiving it - i.e. Client.sentMail() is called
To fix this, I want SMTPClient.smtpState_data() , which uses
FileSender , to wait for the server to finish receiving the message
before proceeding to smtpState_msgSent()
Is this possible?
The only alternative I can think of is to not start sending the message
until after the server finishes receiving it - i.e. start sending the
message after Message.eomReceived() is called. But this seems to me like
it would have worse performance than sending messages at the same time
as they're being received - especially for a message with a large
How can I avoid the client finishing sending the message before the
server finishes receiving it?
More information about the Twisted-Python