发送邮件中的SSL错误

时间:2017-06-25 22:36:46

标签: 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 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

我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

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

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