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

I discovered that while it was possible to use Gmail/Google Apps as an SMTP server for scripted use, if too many emails were sent I started getting error messages:

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

Usually if I waited an hour or two I could send out another 100 emails or so, but I would soon run into the same error message again.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I discovered that the problem was that although we had SPF records set up for our domains, we did not have a DKIM record associated with our domain. 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 google._domainkey.example.com.

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.

share|improve this answer
What if you're not in control of the DNS server? –  Ishmael Oct 7 '13 at 14:56
Thanks dude! You saved my life <3 –  marverix Oct 18 '13 at 16:02

You must not authenticate for each email you should send.

At the beginning of the process:

Session session = loadSession();
Transport transport = session.getTransport("smtp");
transport.connect("example@gmail.com", "password");

After, use the transport object for send each mail without start session:

transport.sendMessage(message, message.getAllRecipients());

After you send all emails, you should close the connection:

share|improve this answer

Your Answer


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.