我正在尝试使用 python 发送电子邮件,但出现 SSL 错误,我不知道为什么。
File "./test.py", line 735, in <module>
mail() File "./test.py", line 721, in mail
server.starttls() File "/usr/local/lib/python2.7/smtplib.py", line 641, in starttls
raise RuntimeError("No SSL support included in this Python") RuntimeError: No SSL support included in this Python
如何添加 SSL 支持?
它只是一个小函数来测试我是否可以用 python 发送电子邮件
def mail():
import smtplib
global log_location
#inFile_list = open(log_location, 'r')
#msg = inFile_list.readlines()
#inFile_list.close()
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
#Next, log in to the server
server.login("my username", "my password")
#Send the mail
msg = "\nHello!" # The /n separates the message from the headers
server.sendmail("mymail@gmail.com", "mymail@gmail.com", msg)
server.quit()
最佳答案
尝试手动安装 _ssl.so 但没有成功。
我已经从 2.7.6 升级到 2.7.7,现在我可以导入 SSL。
关于python - 发送带有 python SSL 错误的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24229449/