Did I find the right examples for you? yes no

All Samples(10)  |  Call(7)  |  Derive(0)  |  Import(3)
Renders an email template with this format:
    {% if subject %}Subject{% endif %}
    {% if message %}Email body{% endif %}

context can be a dictionary or a template.Context instance

        def send_email_template(template, context, to, email_from=None, html=None):
    """
    Renders an email template with this format:
        {% if subject %}Subject{% endif %}
        {% if message %}Email body{% endif %}
    
    context can be a dictionary or a template.Context instance
    """
    from django.template.loader import render_to_string
    from django.template import Context
    if isinstance(context, dict):
        context = Context(context)
    if type(to) in [str, unicode]:
        to = [to]
    
    if not 'site' in context: # fallback site value
        context.update({'site': get_controller_site()})
    
    #subject cannot have new lines
    subject = render_to_string(template, {'subject': True}, context).strip()
    message = render_to_string(template, {'message': True}, context)
    msg = EmailMultiAlternatives(subject, message, email_from, to)
    if html:
        html_message = render_to_string(html, {'message': True}, context)
        msg.attach_alternative(html_message, "text/html")
    msg.send()
        


src/c/o/confine-controller-0.10.5/controller/apps/users/models.py   confine-controller(Download)
from django.utils import timezone
 
from controller.utils import send_email_template
from controller.core.validators import validate_ascii, validate_name
from controller.models.fields import NullableCharField, TrimmedCharField
    def send_creation_email(self, site):
        context = { 'request': self, 'site': site }
        to = self.group.get_emails(role=Roles.GROUP_ADMIN)
        template = 'users/created_join_request.email'
        send_email_template(template=template, context=context, to=to)
    def send_acceptation_email(self, site):
        context = { 'request': self, 'site': site }
        template = 'users/accepted_join_request.email'
        to = self.user.email
        send_email_template(template=template, context=context, to=to)
    def send_rejection_email(self, site):
        context = { 'request': self, 'site': site }
        template = 'users/rejected_join_request.email'
        to = self.user.email
        send_email_template(template=template, context=context, to=to)
    def send_creation_email(self, site):
        context = { 'request': self, 'site': site }
        to = User.objects.filter(is_superuser=True).values_list('email', flat=True)
        template = 'users/created_resource_request.email'
        send_email_template(template=template, context=context, to=to)

src/c/o/confine-controller-0.10.5/controller/apps/users/registration/views.py   confine-controller(Download)
from registration.backends.default.views import ActivationView, RegistrationView
 
from controller.utils import send_email_template
from .models import RegistrationProfile
 
                raise ImproperlyConfigured("EMAIL_REGISTRATION_APPROVE must "\
                    "be a valid email address (current value '%s' is not)." % to)
            send_email_template(template=template, context=context, to=to)
 
        return activated

src/c/o/confine-controller-0.10.5/controller/apps/issues/models.py   confine-controller(Download)
 
from controller.models.utils import generate_chainer_manager
from controller.utils import send_email_template
from users.models import Group, Roles, User
 
            'ticket': self,
            'ticket_message': message }
        send_email_template(template, context, emails, html=html_template)
 
    def save(self, *args, **kwargs):