# cat settings.py ... ... EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_SSL = True EMAIL_HOST = 'smtp.qq.com' EMAIL_PORT = '465' EMAIL_HOST_USER = '[email protected]' EMAIL_HOST_PASSWORD = 'passwd' EMAIL_TIMEOUT = 60
啓用SSL安全鏈接。網上看到說是啓用TLS,我這邊試了不行(django 1.11)。
>>> from django.core.mail import send_mail >>> send_mail('Subject here', 'Here is the message', '[email protected]', ['[email protected]'],) 1
遇到的錯誤:
SMTPAuthenticationError: (502, b'Error: command not implemented')
原因:
smtp密碼錯誤。
其他設置可以參考:https://docs.djangoproject.com/en/dev/topics/email/