使用python发送gmail失败
1。pip错误 是的 然后它说使用python发送gmail失败,python,anaconda,smtplib,Python,Anaconda,Smtplib,1。pip错误 是的 然后它说 Could not find a version that satisfies the requirement smtplib (from versions: ) No matching distribution found for smtplib 我证实了这一点 pip install youtube_dl 工作。所以这可能不是皮普的问题 2。导入错误 无论如何,我运行的代码是 import smtplib GMAIL_USERNAME = "someth
Could not find a version that satisfies the requirement smtplib (from versions: ) No matching distribution found for smtplib
我证实了这一点
pip install youtube_dl
工作。所以这可能不是皮普的问题
2。导入错误
无论如何,我运行的代码是
import smtplib
GMAIL_USERNAME = "something"
GMAIL_PASSWORD = "something"
recipient = "something"
body_of_email = "body"
email_subject = "ha"
# The below code never changes, though obviously those variables need values.
session = smtplib.SMTP('smtp.gmail.com', 587)
session.ehlo()
session.starttls()
session.login(GMAIL_USERNAME, GMAIL_PASSWORD)
headers = "\r\n".join(["from: " + GMAIL_USERNAME,
"subject: " + email_subject,
"to: " + recipient,
"mime-version: 1.0",
"content-type: text/html"])
# body_of_email can be plaintext or html!
content = headers + "\r\n\r\n" + body_of_email
session.sendmail(GMAIL_USERNAME, recipient, content)
但Anaconda提示显示了错误
ImportError: cannot import name 'SMTP'
我搞不懂为什么会发生这种奇怪的事情。你支持代理吗?@crisron你是什么意思?代理?,我是说代理server@crisron我不会用那种东西。我在家里的桌面上用足够快的互联网连接运行这段代码。这就是此代码失败的原因吗?请尝试
pip安装--pre-smtplib
。
ImportError: cannot import name 'SMTP'