0

I'm using Flask-Mail to connect to my TLS-enabled Gmail account. Gmail server is sending email in development but when I use the same configs in production on PythonAnywhere Google blocks it.

app configs:

app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_DEBUG'] = True
app.config['MAIL_USERNAME'] = 'not_really_real@gmail.com'
app.config['MAIL_PASSWORD'] = 'hakunamatata'
app.config['MAIL_DEFAULT_SENDER'] = None
app.config['MAIL_SUPPRESS_SEND'] = False
app.config['DEBUG'] = False

error output from log:

2020-05-15 11:00:30,374: reply: b'534-5.7.14 <https://accounts.google.com/signin
/continue?sarp=1&scc=1&plt=AKgnsbv\r\n'
2020-05-15 11:00:30,374: reply: b'534-5.7.14 oxngN3wR6W-Y9cpG25Ukl-pska7XdVPprbwY7Kbo-YIKDgX3uBKMC5EtBrLsPEZ_KQr9o\r\n'
2020-05-15 11:00:30,374: reply: b'534-5.7.14 yH2as6SxNhxW2uYRmWriQFM4eSGDsuhmqvU40HYZvKb9DYPdUkuLtnW87gMqA4bt>\r\n'
2020-05-15 11:00:30,374: reply: b'534-5.7.14 Please log in via your web browser and then try again.\r\n'

What can I do ? I already reviewed Google settings and allowed everything it considered suspicious.

mr_incredible
  • 837
  • 2
  • 8
  • 21

1 Answers1

1

There was an additional step I needed to do. When something like this happens to anyone in the future try navigating to google.com/blocked and follow the instructions. Basically, Google will give you a time-limited window for letting it know about device you're not normally using for signing in. So next time Google won't block it because you allowed that (often remote) device or server to access your account.

This comment helped me with the problem:

I completely agree with @Abdillah. In fact, after this worked for me, Google then sent me an SMS on my cell phone about a suspicious activity and asking to visit google.com/blocked !! – Fr0zenFyr May 20 '15 at 21:54

found here

mr_incredible
  • 837
  • 2
  • 8
  • 21