Google SMTP Error: 454 4.7.0

This morning, I tried to send around 1/2 thousand of emails using an Google App Email account from my Django app along with celery and django-mailer. But after 100 messages were sent, the celery task cannot send email, and I got this error:

Google SMTP Error: 454 4.7.0 Too many login attempts, please try again later

There are something I need to do to solve this:

1. Add a DKIM record in Google Apps: following this stackoverflow question:

In order to add a DKIM record in Google Apps, you need to do the following:

  • Go to the Admin Console
  • Click on "Google Apps"
  • Click on "Gmail"
  • Scroll down until you see "Authenticate Email" and click that
  • Select the domain you wish to add DKIM to
  • When it asks what prefix you want to use, simply use the default of 'google'

You will then see a TXT record in two parts, one piece has the domain and the other has the actual TXT record. You need to go into your DNS settings on your server for your domain and add this record. If your DNS control panel does not allow you to add the domain of google._domainkey, simply make the domain fully qualified like

After you do this, give the DNS record a little bit of time to propagate and then click "Start Authentication" in the Google Apps admin panel. If you see a green checkmark, you've done it, and email should start flowing through the SMTP server once again.

2. Don't call mailer.engine.send_all method at the end of the email celery task. Instead, create a separate celery periodic task to call send_all:

from celery.decorators import periodic_task
from datetime import timedelta

def send_all_mails():