python - 发送带有 python SSL 错误的电子邮件

标签 python python-2.7 ssl

我正在尝试使用 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/

相关文章:

python - 当我尝试使用opencv和camgear从youtube获得实时流时,出现以下错误

Python 属性实例行为

python-2.7 - Python int 太大,无法在 python 3.4 中转换为 C long

svn - SSL:目的地更改 IP 地址后无法识别证书

python - 我对运行 Django 测试有点困惑

Python 方法查找规则

python - 如何从包含类定义的 .py 文件中获取属性名称

Python 单元测试和测试发现

ssl - 当两个主机都使用 ssl 时,nginx 重定向到错误的 vhost

ssl - 如何为信任库中的根证书配置 Elytron?