Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # We should all know what this is used for by now.
- from django.core.mail import send_mail
- # get_template is what we need for loading up the template for parsing.
- from django.template.loader import get_template
- # Templates in Django need a "Context" to parse with, so we'll borrow this.
- # "Context"'s are really nothing more than a generic dict wrapped up in a
- # neat little function call.
- from django.template import Context
- # Some generic stuff to parse with
- username = "fry"
- password = "password_yo"
- full_name = "Philip J Fry"
- # Our send_mail call revisited. This time, instead of passing
- # a string for the body, we load up a template with get_template()
- # and render it with a Context of the variables we want to make available
- # to that template.
- send_mail(
- 'Thanks for signing up!',
- get_template('templates_path/email.html').render(
- Context({
- 'username': username,
- 'password': password,
- 'full_name': full_name
- })
- ),
- 'admin@moxlee.com',
- ['users_email@gmail.com'],
- fail_silently = True
- )
Add Comment
Please, Sign In to add comment