Kabiljan Tanaguzov
Kabiljan Tanaguzov

Reputation: 323

Django email not sent, but executed in the console

I have a sender for a password change signal. When I use endopint, it should send an email, but it only does it in the console.

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = '465'
EMAIL_HOST_USER = "*******"
EMAIL_HOST_PASSWORD = "******"
EMAIL_USE_SSL = True
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = "*******"

Console successfully outputs:

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: =?utf-8?b?0JTQvtCx0YDQviDQv9C+0LbQsNC70L7QstCw0YLRjCDQvdCwIHNpenpl?=
From: ********
To: [email protected]
Date: Sat, 13 Feb 2021 16:30:12 -0000
Message-ID: 
 <161323381275.176437.7948111011454591000@kabiljan-Lenovo-IdeaPad-S340-14API>

/user/password_reset/?token=d2883b6ae18eb357ac1
-------------------------------------------------------------------------------

what could be the problem?

Upvotes: 2

Views: 1264

Answers (2)

Surya Bista
Surya Bista

Reputation: 564

SMTP backend¶

The SMTP backend is the default configuration inherited by Django. If you want to specify it explicitly, put the following in your settings:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

If unspecified, the default timeout will be the one provided by socket.getdefaulttimeout(), which defaults to None (no timeout) .

Console backend¶

Instead of sending out real emails the console backend just writes the emails that would be sent to the standard output. By default, the console backend writes to stdout. You can use a different stream-like object by providing the stream keyword argument when constructing the connection.

To specify this backend, put the following in your settings:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

This backend is not intended for use in production – it is provided as a convenience that can be used during development.

you are using console backend in setting. Replace the console backend with SMTP backend.

Upvotes: 5

Pranta chakraborty
Pranta chakraborty

Reputation: 304

change the "EMAIL_BACKEND" to this

 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

Upvotes: 1

Related Questions