On Sat, 8 Dec 2007 22:54:45 +0000, James Brady <[EMAIL PROTECTED]> wrote:
Hi all,
I'm a complete Twisted newcomer, so still getting to grips with the ways
thing work..

What I'm trying to do is submit a POST request when I receive email into my
SMTP server.

At the moment, I've basically modified emailserver.tac from the examples (
http://twistedmatrix.com/projects/mail/documentation/examples/emailserver.tac
)

My eomReceived message has this code added to it:
...
       client = getPage(url='http://localhost:8080/message_event_notify',
method='POST',
           postdata=urlencode(postdata),
           headers={ 'Content-Type': 'application/x-www-form-urlencoded' }
)
       client.addCallback(self.success)
       client.addErrback(self.failure)
       reactor.run()


You don't need to call reactor.run() here - the reactor is already running
(that's how the SMTP server works, after all).  In fact, you can't call
reactor.run() here - the reactor mainloop is not reentrant.

Instead, you probably want to return the "client" Deferred from eomReceived.
The SMTP protocol code will use that Deferred to know when to indicate to
the SMTP client which is talking to it when the message has been delivered
successful or if there is an error.

Jean-Paul

_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to