Wednesday, May 18, 2016

Django send_mail smtp gmail

Hi,

I have set up smtp with a gmail account. When I use send_mail the from email is not showing up in the account receiving the email.

Django settings.py

# DEFAULT_FROM_EMAIL = 'sendTo@gmail.com'
EMAIL_BACKEND
= 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST
= 'smtp.gmail.com'
EMAIL_PORT
= 587
EMAIL_HOST_USER
= 'sendTo@gmail.com'
EMAIL_HOST_PASSWORD
= '**********'
EMAIL_USE_TLS
= True

Using 

$ python manage.py shell

I send the mail as follows,

>>> from django.core.mail import send_mail
>>> send_mail('subject is', 'message is and is not 12342', 'fromEmail@gmail.com', ['sendTo@gmail.com'])
1
>>>

I am receiving this email in my gmail account, incidently which is the same gmail account used for the smtp, but the from email is showing up as the sendTo@gmail.com and should be fromEmail@gmail.com

Any help would be greatly appreciated,

Thanks,

Shane



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ee382612-fe68-4118-9bf0-5f51692c5521%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment