[Tutor] Full code i get error when i send email using python
boB Stepp
robertvstepp at gmail.com
Sat May 9 13:25:10 EDT 2020
I have spent the past couple of days getting mutt to work with my Gmail
account. Some of that might be relevant to what you are attempting.
On Sat, May 09, 2020 at 04:31:16AM -0400, Michael Crooks wrote:
> import smtplib
>
> host = "smtp.gmail.com"
> port = 587
> username ="testingprogramsmichael at gmail.com"
> password = "Oliver17"
> from_email = username
> to_list = ["testingprogramsmichael at gmail.com"]
Gmail will not allow you to connect with just a user name and password like
you would in its web interface when you are trying to access it programmatically.
As far as I can tell you have three possibilities to satisfy Gmail
authentication requirements:
1) Generate an application-specific password for your Google account (your
only option if you are using two-factor authentication). See https://support.google.com/accounts/answer/185833
2) Turn on less-secure app access (not an option with two-factor
authentication). See https://myaccount.google.com/lesssecureapps?pli=1
[The above two points were copied near verbatim from https://unix.stackexchange.com/questions/226936/how-to-install-setup-mutt-with-gmail-on-centos-and-ubuntu]
3) There are ways to use OAuth2.0, but it appears to be more complicated.
I will leave it to you to search for articles on using this with Gmail if
it is relevant to your use case.
Guessing from what you are appearing to be trying to do I would guess that
option (1) might be the way to go. It is designed to generate an
app-specific user name/password combination, so that if these become public
(As your "test account" credentials above have become ~(:>)) ) only that
app has been compromised, not your entire Google account.
--
Wishing you only the best,
boB Stepp
More information about the Tutor
mailing list