在 python 3.8.3 中尝试使用 smtplib 发送电子邮件时出错
Giving error when trying to send a email with smtplib in python 3.8.3
当我 运行 程序或尝试更新 smtplib 时出现错误。这是错误:
Here is the picture
我正在使用 python 3.8.3。任何帮助将不胜感激!
这是我的代码:
# from your Gmail account
import smtplib
# list of email_id to send the mail
li = ["example2@gmail.com(email)", "example3@outlook.com(email)"]
for dest in li:
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login("example1@gmail.com(email)", "example1(password)")
message = "Message_you_need_to_send"
s.sendmail("example1@gmail.com(email)", dest, message)
s.quit()
这是错误:
Traceback (most recent call last):
File "d:/Auto_Email/Auto_Email3.py", line 16, in <module>
server.login(username,password)
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 734, in login
raise last_exception
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 723, in login
(code, resp) = self.auth(
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 646, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials d9sm5982379qtq.56 - gsmtp')
PS D:\Auto_Email> pip install update smtplib
Collecting update
Using cached update-0.0.1-py2.py3-none-any.whl (2.9 kB)
ERROR: Could not find a version that satisfies the requirement smtplib (from versions: none)
ERROR: No matching distribution found for smtplib
我已经尝试更新 smtplib(如上所示)并尝试了不同的用户名和密码,但都出现了同样的错误。我还允许访问我的 google 帐户。
如果问题仍然存在,您需要先转到 google 帐户安全设置并允许不安全的应用程序访问该帐户。
当我 运行 程序或尝试更新 smtplib 时出现错误。这是错误:
Here is the picture
我正在使用 python 3.8.3。任何帮助将不胜感激!
这是我的代码:
# from your Gmail account
import smtplib
# list of email_id to send the mail
li = ["example2@gmail.com(email)", "example3@outlook.com(email)"]
for dest in li:
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login("example1@gmail.com(email)", "example1(password)")
message = "Message_you_need_to_send"
s.sendmail("example1@gmail.com(email)", dest, message)
s.quit()
这是错误:
Traceback (most recent call last):
File "d:/Auto_Email/Auto_Email3.py", line 16, in <module>
server.login(username,password)
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 734, in login
raise last_exception
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 723, in login
(code, resp) = self.auth(
File "C:\Users\drake\AppData\Local\Programs\Python\Python38\lib\smtplib.py", line 646, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials d9sm5982379qtq.56 - gsmtp')
PS D:\Auto_Email> pip install update smtplib
Collecting update
Using cached update-0.0.1-py2.py3-none-any.whl (2.9 kB)
ERROR: Could not find a version that satisfies the requirement smtplib (from versions: none)
ERROR: No matching distribution found for smtplib
我已经尝试更新 smtplib(如上所示)并尝试了不同的用户名和密码,但都出现了同样的错误。我还允许访问我的 google 帐户。
如果问题仍然存在,您需要先转到 google 帐户安全设置并允许不安全的应用程序访问该帐户。