While I was learning how to use django-registration app, I discover in the tutorial that I need to know 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 nathanostgard.com that show roughly how to do it. Here I’m going to extend a little on how to test it using shell.
- Create a project, django-admin.py startproject gmail
- Edit settings.py with code below:
EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'email@example.com' EMAIL_HOST_PASSWORD = 'yourpassword' EMAIL_PORT = 587
- Run interactive mode, python manage.py shell
- Import the EmailMessage module,
from django.core.mail import EmailMessage
- Send the email,
email = EmailMessage('Subject', 'Body', t=['firstname.lastname@example.org']) email.save()
Hope it help someone 🙂 Reference here.
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 AlreadyHosting.com.
3 Responses to “Sending email via Gmail in Django”
Leave a Reply
You must be logged in to post a comment.