Sep 15

While I was learning how to use django-registration app, I discover in the tutorial that I need to[1] how to send an email for the user to activate the registration.

Thanks to folk at the Django chatroom, they advice me to google ‘django gmail‘ and I discover a post at that show roughly how to do it. Here I’m going to extend a little on how to test it using shell.

  1. Create a project, startproject gmail
  2. Edit with code below:
    EMAIL_USE_TLS = True
    EMAIL_HOST = ''
    EMAIL_HOST_PASSWORD = 'yourpassword'
    EMAIL_PORT = 587
  3. Run interactive mode, python shell
  4. Import the EmailMessage module,
    from django.core.mail import EmailMessage
  5. Send the email,
    email = EmailMessage('Subject', 'Body', t=[''])

Hope it help someone 🙂 Reference here.

written by mangoorange \\ tags: , , ,

Best Wordpress Hosting Providers - 2014

All three hosts offer FREE 1-click Wordpress installs making them the best Wordpress hosting providers. For more web hosting reviews be sure to check out

#1 - Bluehost 
Bluehost Review
#2 - iPage 
iPage Review
#3 - HostMetro 
HostMetro Review

3 Responses to “Sending email via Gmail in Django”

  1. 1. Louis Says:

    Hey, thanks for the post – I am doing the same thing that you were doing actually – setting up registration on the site.

    I found that the order of the email settings matter.

    EMAIL_HOST = ‘’
    EMAIL_PORT = 587
    EMAIL_HOST_PASSWORD = ‘mypassword’
    EMAIL_USE_TLS = True

    Using this order I couldn’t send the email, but using the order you have above, I can send it.

    I’d be interested to know how the registration app went for you – that’s my next challenge 😉

  2. 2. Ollie Plonka Says:

    It sounds like you’re creating problems yourself by trying to solve this issue instead of looking at why their is a problem in the first place.

  3. 3. Selim Ober Says:

    Obvious but still…
    There are 2 errors on the 5th step. It should be:

    email = EmailMessage(‘Subject’, ‘Body’, to=[‘’])

    send() instead of save(),
    to instead of t

Leave a Reply

You must be logged in to post a comment.