Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I set up Django Mailer and added the two commands to the crontab:

* * * * *      root     python /srv/www/cpm/manage.py send_mail >> /srv/www/cpm/cron_mail.log
0,20,40 * * * * root     python /srv/www/cpm//manage.py retry_deferred >> /srv/www/cpm/cron_mail_deferred.log

CPM is the directory that holds my Django project.

After restarting cron I fired up my Django project and clicked a link that puts around 600 emails onto the Django Mailer queue. The cron command picked up the queued messages and dutifully started sending the emails.

Each email is addressed to me for now for testing purposes. As expected, emails started pouring in.

However, after about 30 emails, I wanted to stop sending the emails as I wanted to make some changes, and start the process over again (I'm testing the app right now). I went into MySQL and deleted all the records in the django_mailer_queuedmessages table, thinking that will stop any further emails.

The emails kept coming.

I then deleted all the records in django_mailer_messages table, hoping that would stop the emails.

The emails kept coming!

I then deleted all records in every table that starts with django_mailer... and also commented out the crontab lines that have django-mailer in them (the two up above) and restarted cron.

The emails are STILL coming!!

What the heck!? How are they still being sent? Interestingly, each email states that it was sent at the time I clicked Send All Emails (about an hour ago now) and not when they arrived in my inbox. So, I'm not really sure what is going on or how to stop this onslaught of emails!

Hey look, another email just arrived...

EDIT 1

I route all my email through my Google Apps Business email account. I simply connect to Gmail in my Python code in the standard way...

EDIT 2

It stopped... finally. I ended up sending a kill signal to the two processes that had started the cron commands. The only thing I can think that happened is that the django_mailer had stored all the emails in memory and was sending them from there. I had thought that django-mailer would pick an email off the queue (its own queue model), send it, then get the next message. This did not seem to be the case since I could delete the entire queue and messages were still sending. Clearly they existed somewhere else other than the queue stored in the MySQL database.

Kind of confusing...

share|improve this question
add comment

2 Answers

Three step solution:

  1. Remove the entries from your crontab
    I don't know if it's still firing off an email every 60 seconds or not, but remove or comment these lines out so we're sure new mail isn't getting injected.

  2. Dump your mail queue
    …in whatever way is appropriate for your MTA software (since you don't specify your MTA I can't be more specific). This should get rid of any mail waiting to be sent (you may have a substantial backlog)

  3. Test manually and observe your system's behavior This will let you determine what happened, and how to prevent it from happening in the future.

share|improve this answer
    
1: The lines have been commented out for almost an hour now, and I restarted cron, the emails are still coming. 2: The mail queue for Django Mailer has been empty for a while now. I don't know how to dump the mail queue in my Google Apps account, I'm not sure I have access to that. 3: Not even sure what I would be watching for. Everything seemed to be acting normally. –  Garfonzo Jan 25 '12 at 5:20
    
My suspicion is something hinky caused a metric buttload of mail to be puked out by django (this is borne out by the fact that you say they all have the same send time, but check the first received: time in the header to be sure). If that's the case and you can't accomplish (2) you're stuck with waiting until the mail works its way out... –  voretaq7 Jan 25 '12 at 5:41
add comment

Make sure that 'django' itself is not sending the mail messages. Unset your ADMIN directive.

old settings.py

ADMINS = (('Bugs Bunny', 'bugs.bunny@acme.com'),)
MANAGERS = ADMINS

new settings.py

ADMINS = ()
MANAGERS = ADMINS

This will keep django itself from sending emails when something is misconfigured and DEBUG = False

share|improve this answer
    
It turned out to be one of the apps within my project that was the culprit. I use django_mailer and once I hit "send emails" it would queue up all the emails. Then, it would slowly churn through all the emails sending them one by one. What solved it for me was deleting all the queued messages. That way, there was nothing left to send. –  Garfonzo Apr 25 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.