kolas
kolas

Reputation: 23

Why can not get email message (python, gmail, django)?

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.

Upvotes: 1

Views: 493

Answers (1)

Toan Quoc Ho
Toan Quoc Ho

Reputation: 3378

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!

Upvotes: 1

Related Questions