python - Send an email via. deferred library in Google App Engine -
i'm attempting send mail using emailmessage class, which, when used normally, in:
message = mail.emailmessage() message.sender = ... message.to = ... message.subject = ... message.send()
works fine; receive email expected.
however, trying add email.send()
event push queue using deferred library:
def email(): message = mail.emailmessage() message.sender = ... message.to = ... message.subject = ... // elsewhere def send_email(message): deferred.defer(message.send, _countdown=10) app = webapp2.wsgiapplication([ ('/api/email', emailhandler) ], debug=false)
i can see added push queue on admin interface, never receive email or kind of failure notification/bounce message.
i've seen limitations of deferred library don't think i'm running of here?
deferred.defer
takes arguments function , arguments passed function. when this:
deferred.defer(message.send, _countdown=10)
you pass function message.send
data message
object gets lost no longer have data!
instead move of logic send_email
function:
def send_email(from, to, subject, body): message = mail.emailmessage() message.sender = ... message.to = ... message.subject = ... message.send() // elsewhere deferred.defer(send_email, from, to, subject, body, _countdown=10)
Comments
Post a Comment