Guest User

Untitled

a guest
May 31st, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. # We should all know what this is used for by now.
  2. from django.core.mail import send_mail
  3.  
  4. # get_template is what we need for loading up the template for parsing.
  5. from django.template.loader import get_template
  6.  
  7. # Templates in Django need a "Context" to parse with, so we'll borrow this.
  8. # "Context"'s are really nothing more than a generic dict wrapped up in a
  9. # neat little function call.
  10. from django.template import Context
  11.  
  12. # Some generic stuff to parse with
  13. username = "fry"
  14. password = "password_yo"
  15. full_name = "Philip J Fry"
  16.  
  17. # Our send_mail call revisited. This time, instead of passing
  18. # a string for the body, we load up a template with get_template()
  19. # and render it with a Context of the variables we want to make available
  20. # to that template.
  21. send_mail(
  22. 'Thanks for signing up!',
  23. get_template('templates_path/email.html').render(
  24. Context({
  25. 'username': username,
  26. 'password': password,
  27. 'full_name': full_name
  28. })
  29. ),
  30. 'admin@moxlee.com',
  31. ['users_email@gmail.com'],
  32. fail_silently = True
  33. )
Add Comment
Please, Sign In to add comment