django使用smtp發送郵件

# 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/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章