Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Email delivery

Gmail SMTP blocks you with 454 4.7.0 Too many login attempts

Error454 4.7.0 Too many login attempts, please try again later

Short answer

454 4.7.0 is a temporary block. Gmail saw repeated failed sign-ins from your app and told it to wait. Stop the sender, wait, and fix the reason sign-in fails (usually a normal password instead of an app password) before starting it again, or the block returns.

  • Applies to Python 3.12, smtp.gmail.com
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Stop every process that sends through this account, then count how often your app tried to sign in. A queue worker or a cron job in a retry loop is the usual source.

    grep -c -i -E "535|authentication|login" /var/log/myapp/mail.log
  2. 2Match what you see, then jump to its fix

    1. 1The log shows many failed logins in a short time, then 454 4.7.0.Failed sign-ins were repeated until Gmail blocked themFix
    2. 2Before the 454, the same account returned 535 or an app-specific password message.Every attempt fails because the password type is wrongFix

What does the error look like?

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

Cause 1 of 2

Failed sign-ins were repeated until Gmail blocked them

1Check

Google lists 454 4.7.0 as too many sign-in attempts and says to try again later. The block is caused by repeated failures, so look at what the earlier errors said.

grep -E "535|534|530" /var/log/myapp/mail.log | tail -n 20

2Fix

Stop the loop and wait before the next try. Make the sender give up on an authentication error instead of retrying it, because retrying the same wrong credentials only prolongs the block.

import smtplib
try:
    server.login(user, app_password)
except smtplib.SMTPAuthenticationError:
    raise SystemExit("credentials rejected: fix them, do not retry")

3Verify

After the wait, one login attempt succeeds and the log shows no repeat attempts.

grep -c "454" /var/log/myapp/mail.log

Confirmed by knowledge.workspace.google.com

Did this fix it?

Cause 2 of 2

Every attempt fails because the password type is wrong

1Check

Google answers a plain password with 535 when the account needs an app password (it lists an application-specific password required message). Workspace accounts have no password sign-in for apps since 1 May 2025.

grep -E "535|5\.7\.8" /var/log/myapp/mail.log | head

2Fix

Create an app password for the account (2-Step Verification must be on) or move to OAuth, then update the app and start it once.

MAIL_USERNAME=me@gmail.com
MAIL_PASSWORD=<app password>

3Verify

One test send passes; see the 535 page if it does not.

python3 -c "import smtplib,ssl; s=smtplib.SMTP('smtp.gmail.com',587); s.starttls(context=ssl.create_default_context()); s.login('me@gmail.com','APP_PASSWORD'); print('ok')"

Confirmed by support.google.com

Did this fix it?

How do I stop it coming back?

  • Treat an authentication error as final in your mail code: log it once and alert, no automatic retry.
  • Keep the volume inside the limit Google lists for smtp.gmail.com: 2,000 messages per day on Workspace.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Email

Django send_mail fails or hangs with an SSL error

smtplib.SMTPException raised from send_mail()

Django has two secure modes that must not be mixed: EMAIL_USE_TLS for explicit TLS (STARTTLS, usually port 587) and EMAIL_USE_SSL for implicit TLS (usually port 465).

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.