SMTP authentication troubles with Zapier and PythonAnywhere

I’m hitting a snag with my Python backend setup on Zapier and PythonAnywhere. For months, everything was smooth sailing, but now I’m getting a 534 error when trying to send emails. Here’s the gist of the error message:

SMTPAuthenticationError: (534, '5.7.14 Please log in via your web browser and then try again.')

I’ve double-checked my code, and it seems fine. I’m using Gmail’s SMTP server and have enabled ‘less secure apps’ in the settings, but that hasn’t solved it.

Below is a simplified version of my code:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

sender_email = '[email protected]'
receiver_email = '[email protected]'
password = 'mypassword'

message = MIMEMultipart()
message['From'] = sender_email
message['To'] = receiver_email
message['Subject'] = 'Test Email'

body = 'This is a test email sent from Python.'
message.attach(MIMEText(body, 'plain'))

server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, password)
server.send_message(message)
server.quit()

Has anyone else encountered this problem recently? Any ideas for a workaround?

I’ve dealt with this exact issue before. The problem likely stems from Google’s increasingly strict security measures. Here’s what worked for me:

First, enable two-factor authentication on your Google account if you haven’t already. Then, generate an app password specifically for your Python script. This bypasses the usual login process and should resolve the 534 error.

Also, double-check your SMTP settings. Make sure you’re using port 587 and that TLS is enabled. Sometimes, small configuration errors can cause big headaches.

If that doesn’t work, try logging into your Google account from the same IP address as your script. This can sometimes ‘unlock’ the account for automated access.

Remember, Google’s security policies change frequently, so what worked yesterday might not work today. Stay vigilant and be prepared to adapt your authentication method as needed.

hey there! i ran into this too. google’s gettin real picky bout security. try this: set up 2factor auth on ur account, then make an app password for ur script. that usually fixes it. also, double check ur using port 587 and TLS is on. goodluck!

I encountered a similar issue recently and resolved it by generating an app-specific password. I enabled two-step verification in my Google Account and then created a dedicated password for my script. This solution bypassed the usual security checks and allowed the SMTP authentication to work correctly. I also discovered that ensuring the server’s clock was synchronized played a crucial role, as even minor discrepancies can cause SSL-related errors. Overall, while the process took some time, it ultimately restored my email functionality.