Search code examples
google-app-enginedjango-nonrel

Keep receiving email from Django app on GAE


In a Django app powered by django nonrel on google app engine, I have the following code which is supposed to send me an email if a particular case happens. However, whenever this event is triggered, I get this email repeatedly every hour or so. Does anyone know how I can make this not happen or what is causing this to happen?

    if reply_meaning==5:    #not clear
        text_template = get_template('email/clarify.txt')
        html_template = get_template('email/clarify.html')
        context = Context({
                          'message' : reply,
                          'invitation_id' : invitation.id,
                          })
        text_message = text_template.render(context)        
        html_message = html_template.render(context)        
        message = mail.EmailMessage(
                                    sender = to_address,
                                    to = "MY_EMAIL_ADDRESS",
                                    subject = "not clear",
                                    body = text_message,
                                    html = html_message,
                                    )
        message.send()

Solution

  • If you're calling send() in a task queue task, and you get an exception in that task, the task will be re-queued, and your mail will be sent again. You should check your logs (or add logging) to see if send() is being called multiple times.