[Twisted-Python] Multiple transmissions via SMTPClient

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sun May 27 14:39:21 EDT 2012


On 23 May, 07:10 pm, jasonjwwilliams at gmail.com wrote:
>Hi Guys,
>
>I've been banging my head on this for a few days so I thought I'd ping
>folks here. Been trying to modify twisted.mail.smtp.ESMTPClient to
>allow the sending of more than one message over a single TCP
>connection. I've changed the  behavior of smtpState_data() so that it
>sets the next state to smtpState_from if there is another message to
>send, and this seems to work unless there's an error returned by the
>server.

Are you sure you need to do this?  The behavior is already to go back 
from "from" after "data" (by way of a RSET command).
>In this case the connection is still closed on the client side
>after smtpState_msgSent, and I need to suppress this. The subsequent
>message should still be sent on the open TCP connection error or not,
>according to my needs, however I'm having a heck of time tracking down
>where the disconnection is occurring.
>
>My current code (with debugging statements) is here:
>https://gist.github.com/2777154
>
>Any help is greatly appreciated. This client is being used to run
>functional tests.

The method referred to by the attribute `_failresponse` is called if the 
server responds with an unexpected code.  Set that to a different 
handler, to handle failures from the server differently.

Jean-Paul



More information about the Twisted-Python mailing list