Skip to content

Instantly share code, notes, and snippets.

@ragowthaman
Created August 2, 2016 08:16
Show Gist options
  • Select an option

  • Save ragowthaman/f7315ddfe7c9c9abbba4b9a81d3c3037 to your computer and use it in GitHub Desktop.

Select an option

Save ragowthaman/f7315ddfe7c9c9abbba4b9a81d3c3037 to your computer and use it in GitHub Desktop.
Enable Django app with emailing (send_mail + gmail)
# Email/gmail configuration
# console.EmailBackend is to test the email on console in dev mode
# comment next line to spit emails on console for testing (of course comment the line next to it)
# EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'
# smtp.EmailBackend is for the production server
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER='[email protected]'
EMAIL_HOST_PASSWORD='password'
EMAIL_USE_TLS=True
# send an email
recipient_list = ["[email protected]", "[email protected]"]
email_message = "A new consultant got registered into vidhaikalam. First Name: %s <p> Last Name: %s \n Id: %s" % \
(consultant_obj.firstname, consultant_obj.lastname, consultant_obj.id)
send_mail("New consultant registered!", email_message, settings.DEFAULT_FROM_EMAIL,
recipient_list, fail_silently=False, auth_user=None,
auth_password=None, connection=None, html_message=None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment