Sending Email Using Gmail Account in Django

June 23rd, 2010

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.

1
2
3
4
5
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
1
2
>>> 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. Email Validation Challenge
  4. Getting Started With Django-CMS
  5. How to Reset Django Admin Password

Tags:

One Comment