1

all. Have a troubles with email sending in django. Have next in my settings.py

EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = '[email protected]'

Try to call function send_mail from django.core.mail:

 send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,
           ['[email protected]', ], fail_silently=False)

Have next output:

Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Subject here From: [email protected] To: [email protected] Date: Mon, 23 Sep 2019 09:57:10 -0000 Message-ID: <20190923095710.1383.3314> Here is the message.

But I have not any messages in my mail client. Have checked Spam folder too - it's empty.

6
  • the output shown on your console? Commented Sep 23, 2019 at 10:09
  • @Toan Quoc Ho Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Subject here From: [email protected] To: [email protected] Date: Mon, 23 Sep 2019 09:57:10 -0000 Message-ID: <20190923095710.1383.3314> Here is the message. Commented Sep 23, 2019 at 10:10
  • If it showed on your console, I worry that some where the code already overridden the EMAIL_BACKEND, EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'. make sure that there is no line of code like this Commented Sep 23, 2019 at 10:15
  • @Toan Quoc Ho , yes I have a lot of "----" at the last line of console output Commented Sep 23, 2019 at 10:21
  • I mean you should make sure that EMAIL_BACKEND not be overridden. Make sure that it always has this value EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' Commented Sep 23, 2019 at 10:23

1 Answer 1

1

You email was displayed in the console so seem like your EMAIL_BACKEND was overridden by django.core.mail.backends.console.EmailBackend. Make sure that there is no line of code which override your EMAIL_BACKEND and the value of EMAIL_BACKEND setting always is django.core.mail.backends.smtp.EmailBackend.

Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.