Posted By

martin_rusev on 01/16/10


Tagged

email html django


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

pjv


Send HTML templates with Django


 / Published in: Django
 

  1. from django.template import loader, Context
  2.  
  3. t = loader.get_template('registration/email.txt')
  4. c = Context({
  5. 'name': form.cleaned_data['first_name'],
  6. 'website_name': 'Website Name',
  7. 'website_url': 'http://www.yourwebsite.com/',
  8. 'login_url': 'http://www.yourwebsite.com/login/',
  9. 'username': form.cleaned_data['username'],
  10. })
  11.  
  12.  
  13.  
  14. from django.core.mail import send_mail
  15.  
  16. send_mail('Thanks for registering at your website', t.render(c), '[email protected]', [form.cleaned_data['email']], fail_silently=False)

Report this snippet  

You need to login to post a comment.