Thursday, 29 December 2011

Sending email via Gmail in Django

While I was learning how to use django-registration application, I need to know that how to send an email for the user to activate the registration.
During this post I want to show how to test it using shell, 
  1. Create a project, startproject pjtname
  2. Edit with code below:
         EMAIL_USE_TLS =True
         EMAIL_HOST = ''
         EMAIL_HOST_USER = ''
         EMAIL_HOST_PASSWORD = 'your password'
         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', to=['receiver email id'])

No comments:

Post a Comment