38👍
You have made a typo in your settings. TLS should be set with EMAIL_USE_TLS
not MAIL_USE_TLS
. Not using TLS while connecting to 587 generates this error.
6👍
Make sure you have also set the EMAIL_BACKEND
setting:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
- How can I automatically let syncdb add a column (no full migration needed)
- How to test (using unittest) the HTML output of a Django view?
- Python/Django development, windows or linux?
- Django request.user.is_authenticated is always true?
- Does Django have a Windows 7 Installer? I couldn't find one and theres little mention of Windows
5👍
This response is late for the question; but will hopefully help future readers of this thread.
As pointed out by @WAF, EMAIL_USE_TLS = True resovles this error.
Additionally, if the resolution is being validated via the shell command of the django manage tool, we’ll have to restart the shell after adding the above setting & repeat the validation steps.
The following summarizes the minimal config for gmail validation from django shell:
In settings.py:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '<email.id>'
EMAIL_HOST_PASSWORD = '<pw>'
EMAIL_USE_TLS = True
In the shell of the django manage tool:
from django.core.mail import send_mail
send_mail('From django', 'Test email from dj manage', 'from@example.com', ['to@example.com'])
... 1
- Advanced Django Template Logic
- Django docker – could not translate host name "db" to address: nodename nor servname provided, or not known
- DateTimeField received a naive datetime
- Django queryset filter GT, LT, GTE, LTE returns full object list
- 'QuerySet' object has no attribute ERROR, trying to get related data on ManyToMany fields
5👍
I found the problem… you have to use this code
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
instead of
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
1👍
Once you fix the error by deleting the mail extension, you may receive other errors. In most cases extension is not the real problem. Once you did complete your setup correctly it works both with extension and without.
EMAIL_HOST_USER = 'my_account'
Visit https://myaccount.google.com/security and check if it works when you turn on Allow less secure apps setting at the bottom.
- How to run a Django celery task every 6am and 6pm daily?
- One project, Multiple customers with git?
- Advanced Django Template Logic
- Signing in leads to /accounts/profile/ in Django
1👍
You need to set either TLS
or SSL
to be True
Also, use STARTTLS
port which is 587
Like that:
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
Note: You don’t need to include this in your settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
- Python + Django + VirtualEnv + Windows
- Group models in django admin
- Static files won't load when out of debug in Django
0👍
This is the problem with your SMTP server configuration. It is not configured with TLS.
If you are using postfix please refer to the document –
http://postfix.state-of-mind.de/patrick.koetter/smtpauth/postfix_tls_support.html
It would also helpful for you –
How to send an email with Gmail as provider using Python?
- AttributeError: 'NoneType' object has no attribute 'attname' (Django)
- How to properly query a ManyToManyField for all the objects in a list (or another ManyToManyField)?
- How to get values of all object fields in Django?
-1👍
i deleted :
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
and my settings.py
looks like :
EMAIL_HOST_USER
EMAIL_HOST_PASSWORD
EMAIL_HOST
EMAIL_PORT
EMAIL_USE_TLS
and its worked !!!!
- Auto-creating related objects on model creation in Django
- TypeError: create_superuser() missing 1 required positional argument: 'profile_picture'
- Django rest framework api_view vs normal view