Python 发送邮件时出现SSL错误
我尝试发送meil drom django/但出现错误 [SSL:UNKNOWN_PROTOCOL]未知协议(_SSL.c:661) 我的代码是: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
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