# SMTP: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials

**Code:** `535 5.7.8 Username and Password not accepted` · **Category:** Email / SMTP · **Seen on:** SMTP

The server received your login but rejected it — wrong username or password, an unusable password type, or a blocked sign-in.

## Meaning

Gmail returns this for wrong credentials and also when an app password is needed or the sign-in was blocked. Use the full email address as username, a valid app password (with 2SV), and check Gmail's security alerts for a blocked sign-in. For other providers, confirm SMTP is enabled for the mailbox.

## Common causes

- Wrong password or username (must be full address)
- Account password used instead of an app password
- App password revoked after a password change
- Sign-in blocked as suspicious (new server IP)
- SMTP/IMAP disabled for the mailbox

## Quick fix

1. Re-enter credentials; use the full email as username
2. Generate a new app password
3. Review security alerts and approve the sign-in or unlock captcha: accounts.google.com/DisplayUnlockCaptcha

## Detailed fix by platform

### Python

1. Quick test: `python3 -c "import smtplib;s=smtplib.SMTP('smtp.gmail.com',587);s.starttls();s.login('you@gmail.com','APP_PASSWORD');print('ok')"`

## How to diagnose

1. **User** — Full email address?
2. **Password** — App password if 2SV?
3. **Alerts** — Blocked sign-in?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/email/535-5-7-8-username-password-not-accepted)
