我想配置Django的send_email,以便我可以發送密碼重置電子郵件給用戶。到目前爲止,我沒有運氣讓它工作。我已經建立了一個基本的Gmail帳戶(沒有谷歌應用程序等),並在我的Django settings.py我有:Django通過smtp.gmail.com發送電子郵件的問題
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'my_password'
EMAIL_HOST_USER = '[email protected]'
EMAIL_PORT = 587
MAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = '[email protected]'
然後我嘗試從做測試:
python manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('test', 'test', '[email protected]', ['[email protected]'])
我得到錯誤信息
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Program Files\Python27\lib\site-packages\django\core\mail\__init__.py
", line 62, in send_mail
connection=connection).send()
File "C:\Program Files\Python27\lib\site-packages\django\core\mail\message.py"
, line 255, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\Program Files\Python27\lib\site-packages\django\core\mail\backends\sm
tp.py", line 88, in send_messages
new_conn_created = self.open()
File "C:\Program Files\Python27\lib\site-packages\django\core\mail\backends\sm
tp.py", line 55, in open
self.connection.login(self.username, self.password)
File "C:\Program Files\Python27\lib\smtplib.py", line 577, in login
raise SMTPException("SMTP AUTH extension not supported by server.")
SMTPException: SMTP AUTH extension not supported by server.
有沒有人有一個想法是怎麼回事!任何提示表示讚賞!
是這行是在我的settings.py。還是行不通。 –