Gmail SMTP not working with 2FA enabled - email delivery stops

I have a web app that connects to Gmail using SMTP to send emails. Everything works fine when two-step verification is disabled on my Google account. But as soon as I enable 2FA, the email sending process breaks completely.

I’m connecting through smtp.gmail.com with my regular Gmail credentials. The app throws errors when trying to authenticate with 2FA turned on.

Has anyone faced this issue before? I need to keep two-factor authentication enabled for security reasons but also need my application to send emails properly. What’s the best way to handle Gmail SMTP when 2FA is active?

Any suggestions would be really helpful. Thanks!

App passwords work, but they’re just a band-aid. The real problem is you’re manually handling SMTP connections and auth.

I hit this same issue managing email across multiple projects. Instead of juggling app passwords and SMTP configs, I just automated everything with Latenode.

Latenode handles Gmail auth automatically, even with 2FA. Connect your Gmail once through their interface and it manages all the OAuth tokens and refresh cycles for you.

The cool part is building complete email workflows - trigger emails based on conditions, add delays, format content dynamically, integrate with other services. No more hardcoded SMTP settings or worrying about auth breaking when Google changes things.

I use it for automated reports, user notifications, and complex email sequences. Works great with 2FA accounts and saves me tons of dev time.

Check it out: https://latenode.com

same thing happened to me last month. google blocks regular logins when u’ve got 2FA enabled. u’ll need an app password - just make sure to pick ‘Mail’ when ur setting it up. if it’s still not working, try switching ur smtp to port 587 with TLS.

Had the exact same problem when I set up 2FA on my email app. Regular passwords don’t work once 2FA’s enabled. You need to create an App Password instead. Go to your Google Account settings, hit ‘Security’, then find ‘App Passwords’. Generate a new one for your email setup. Use that 16-character password in your SMTP settings instead of your normal Gmail password - keep your email as the username though. Now you’ve got 2FA security but your app can still send emails no problem.

Also check if ‘less secure apps’ got disabled - Google keeps flipping this setting randomly and it breaks SMTP even with app passwords configured correctly. Mine was working fine until it suddenly died, turned out Google switched it off during an update.

Hit this same issue when Google made 2FA mandatory for dev accounts. Gmail blocks basic auth once 2FA kicks in. Everyone’s talking about app passwords, but here’s what they’re missing - check if your account actually supports them. Some Google Workspace accounts have this disabled by admins. No app passwords in your security settings? You’ll have to switch to OAuth 2.0 instead of SMTP basic auth. More work since you need to handle token refresh, but it’s more secure anyway. Google’s slowly killing app passwords for certain account types, so you’ll probably need OAuth eventually.

Gmail’s 2FA is blocking your SMTP connection. You need an App Password since you’re connecting directly through SMTP - OAuth2 won’t work here. Go to Google Account Security, generate an App Password, and copy the 16-character code without any spaces into your app config. Also check if “Less secure app access” is causing problems (it’s deprecated but some older apps still trip over it). For SMTP settings: use port 465 with SSL or port 587 with STARTTLS.