[Twisted-Python] [twisted.mail][newbie] return tempfail (4xx) after eomReceived()

Fabio Sangiovanni sangiovanni at nweb.it
Sat Nov 23 03:36:01 MST 2013


Hello list,

I'm trying to code an SMTP server that stores received messages in a 
queue (es. RabbitMQ or Redis).
I'm figuring out how to do it with Twisted, and so far I managed to 
print to console the messages the way I want.
I'm trying to understand now how to return a tempfail code (4xx) from 
within eomReceived(), so to simulate (and, in the future, handle) 
temporary unavailabilities of the queuing system, and thus to delegate 
to the client the handling/retrying of the delivery (there will be 
postfix in front of my smtp server, so it will keep the message in its 
spool).
I ended up digging in the code until I found the _messageHandled 
callback of the SMTP class, that's added to the deferred returned by 
eomReceived. I admit I'm not very accustomed to deferreds yet, but I can 
only see 250 and 550 response code inside it. I suspect that I should 
return the 4xx code in one of the deferred's callbacks/errbacks *before* 
_messageHandled, but I really can't imagine how. Would you please give 
me some hints about how to accomplish the task? Am I looking to the 
right direction at all?

Thanks a lot,
Fabio



More information about the Twisted-Python mailing list