Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 发送邮件时出现SSL错误_Python_Django_Ssl - Fatal编程技术网

Python 发送邮件时出现SSL错误

Python 发送邮件时出现SSL错误,python,django,ssl,Python,Django,Ssl,我尝试发送meil drom django/但出现错误 [SSL:UNKNOWN_PROTOCOL]未知协议(_SSL.c:661) 我的代码是: DEFAULT_FROM_EMAIL = 'info@xxxxxxx' html = render_to_string('email/html/new_order.html', {'order': self, 'image_code': True}) email = EmailMultiAlternatives( 'Greetings f

我尝试发送meil drom django/但出现错误 [SSL:UNKNOWN_PROTOCOL]未知协议(_SSL.c:661)

我的代码是:

DEFAULT_FROM_EMAIL = 'info@xxxxxxx'

html = render_to_string('email/html/new_order.html', {'order': self, 'image_code': True})

email = EmailMultiAlternatives(
    'Greetings from Discovery Russia',
    html,
    DEFAULT_FROM_EMAIL,
    to=[self.user_email, 'info@.xxxxxx'])

email.attach_alternative(html, "text/html")
email.mixed_subtype = 'related'

try:
    email.send()
except SMTPRecipientsRefused:
    pass

如何修复?

您是否将电子邮件设置添加到您的设置.py?像这样:

DEFAULT_FROM_EMAIL = 'xxxxx@gmail.com'
EMAIL_HOST_USER = 'xxxx@gmail.com'
EMAIL_HOST_PASSWORD = 'xxxxxxx'
EMAIL_USE_TLS = False
EMAIL_PORT = 1025