Cannot set Django to work with smtp.gmail.com

前端 未结 5 1618
不知归路
不知归路 2021-01-01 13:05

I\'ve been trying to get django to work with gmail\'s smtp server to send mails but I always get this traceback. Any help will be most appreciated.

----- settings.p

5条回答
  •  借酒劲吻你
    2021-01-01 13:12

    Change your settings like this :

    EMAIL_HOST = 'smtp.gmail.com'
    
    EMAIL_HOST_USER = 'user'
    
    EMAIL_HOST_PASSWORD = 'your-password'
    
    EMAIL_PORT = 587
    
    EMAIL_USE_TLS = True
    

    Then try:

    python manage.py shell
    >>> from django.core.mail import EmailMessage
    >>> email = EmailMessage('Mail Test', 'This is a test', to=['somemail@something.com'])
    >>> email.send()
    

    This should return with the status 1, which means it worked.

提交回复
热议问题