48👍
for me in settings.py:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'test@gmail.com'
EMAIL_HOST_PASSWORD = 'test'
EMAIL_PORT = 587
and views.py:
from django.core.mail import EmailMessage
email = EmailMessage('title', 'body', to=[email])
email.send()
and: https://accounts.google.com/DisplayUnlockCaptcha
and also make sure you turn on permission for less secure apps.
22👍
Remember to:
Go to your Google Account settings, find Security -> Account permissions -> Access for less secure apps, enable this option.
About this option: https://support.google.com/accounts/answer/6010255
- [Django]-Removing help_text from Django UserCreateForm
- [Django]-Django logging of custom management commands
- [Django]-Django BooleanField as radio buttons?
12👍
I tested this and worked perfect in django 1.8:
first you should check this link, provided by google which you did 🙂
notice that for some strange reasons that I don’t know,you have to code like this in view.py or shell
:
import django
from django.conf import settings
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,
['to@example.com'], fail_silently=False)
also this is my settings in setting.py
file:
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'xxxx' #my gmail password
EMAIL_HOST_USER = 'xxxx@gmail.com' #my gmail username
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
- [Django]-Django-tables2: How to use accessor to bring in foreign columns?
- [Django]-Django – No module named _sqlite3
- [Django]-Django rest framework, use different serializers in the same ModelViewSet
9👍
replace in your settings.py file :
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
by
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
- [Django]-Python Django Gmail SMTP setup
- [Django]-How to use permission_required decorators on django class-based views
- [Django]-Easiest way to rename a model using Django/South?
8👍
In settings.py
change this
EMAIL_HOST='imap.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'yadavabhishek260@gmail.com'
EMAIL_HOST_PASSWORD ='**********'
EMAIL_USE_SSL=False
EMAIL_USE_TLS= True
- [Django]-Django: AppRegistryNotReady()
- [Django]-Tell if a Django Field is required from template
- [Django]-Django forms, inheritance and order of form fields
1👍
This works for me:
settings.py
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'test'
EMAIL_HOST_USER = 'test@gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Unlock Captcha: https://accounts.google.com/DisplayUnlockCaptcha
views.py
email = EmailMessage(
'subject_message',
'content_message',
'sender smtp gmail' +'<sender@gmail.com>',
['receiver@gmail.com'],
headers = {'Reply-To': 'contact_email@gmail.com' }
)
email.send()
- [Django]-Django models | get specific columns
- [Django]-How to work around lack of support for foreign keys across databases in Django
- [Django]-Django: How to set a field to NULL?
1👍
I used this for django 1.11
In settings.py
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'sender' #sender mail password
EMAIL_HOST_USER = 'sender@mail.com' #sender mail username
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
In view.py
send_mail('mail subject', 'body content',settings.EMAIL_HOST_USER,
['receiver@mail.com'], fail_silently=False)
and goto https://myaccount.google.com/u/0/security?hl=en to enable Less secure app access
- [Django]-Django: Force select related?
- [Django]-Get SQL query count during a Django shell session
- [Django]-Django formsets: make first required?