|
Sep 15
|
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 = 'youremail@gmail.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=['mickeyckm@mangoorange.com']) email.save()
Hope it help someone
Reference here.



