Sending Email Using Gmail Account in Django

djangoSending email in Django is easy, just add a few lines in your settings.py and you have everything ready to send an email. But if you’re using Gmail as your SMTP server you need add a few more lines to your settings.py. You need to specify what port Gmail server using and set to use TLS.

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'your-username@gmail.com'
EMAIL_HOST_PASSWORD = 'your-password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

You can go to the shell to test it:

$python manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('test email', 'hello world', to=['test@komunitasweb.com'])

That’s it, now you can have Gmail SMTP server in Django.

Related posts:

  1. Receiving Email Using AppEngine and Django
  2. Django Tutorial – Simple Notes Application
  3. Set Different Settings for Development in Django
  4. Email Validation Challenge
  5. Relative Path for your Django Project

Tags:

2 Tweets

3 Responses to “Sending Email Using Gmail Account in Django”

  1. [...] This post was mentioned on Twitter by KomunitasWeb, Django Ireland. Django Ireland said: Sending Email Using Gmail Account in Django | KomunitasWeb http://bit.ly/a87dYT [...]

    Pingback by Tweets that mention Sending Email Using Gmail Account in Django | KomunitasWeb -- Topsy.com — June 23, 2010 @ 7:51 am

  2. New blog posting, Sending Email Using Gmail Account in Django – http://tinyurl.com/39vse5q

    This comment was originally posted on Twitter

    Comment by komunitasweb — June 23, 2010 @ 6:46 am

  3. Sending Email Using Gmail Account in Django | KomunitasWeb http://bit.ly/a87dYT

    This comment was originally posted on Twitter

    Comment by DjangoIreland — June 23, 2010 @ 7:39 am

Additional comments powered by BackType