How To Send An Email Through Gmail Using Python?
Solution 1:
Google has recently tightened their security. Application that use username/password directly have been deactivated. All users are still able to reactivate these less secure application in their security settings as you have been reading in the link you gave in your question. This is the only solution at this point.
The alternative would be to use an other SMTP server for sending.
Solution 2:
The error message you quote says
[..] Please log in via your web browser and then try again.
5.7.14 Learn more at
5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754
This was already discussed in server send emails using gmail smtp gets alerts.
So I'd say that your code is fine and you're dealing with a Google-specific security mechanism.
Solution 3:
You could enable Google's 2-step authentication and then generate an application-specific password for your script. I do the same (I also have similar code as you) and it works fine.
Post a Comment for "How To Send An Email Through Gmail Using Python?"