steambird/mail/mailsender.py
def create_email(template_name: str, subject: str, context: dict,
                 **kwargs) -> EmailMessage:
    """
    Attempts to create an email that only has a single language, which is
    pulled from the context using get_language.

    If it cannot send the email in the requested language, it will call
    create_multilingual_email to send an email in all the languages that are
    available.

    :param template_name: The template that should be used for this email
    :param subject: The subject of this email
    :param context: The context for the template
    :param kwargs: Any other data that should be passed to the EmailMessage
        constructor
    :return: an EmailMessage
    """
    _ensure_setup()
    lang = get_language()
    kwargs['headers'] = kwargs['headers'] if 'headers' in kwargs else {}

    kwargs['headers'] = {
        "X-Mailer": get_mailer_name(),
        "Content-Language": lang,
        **kwargs['headers']
    }

    langs = templates[template_name]
    if lang in langs:
        tpls = langs[lang]

        msg = MultiTemplatableEmailMessage(
            subject=_(subject),
            body=False,
            **kwargs
        )

        for template in tpls:
            msg.attach_alternative(
                SafeMIMEText(
                    _text=get_template(template['file']).render({
                        'locale': template['locale'],
                        **context,
                    }),
                    _subtype=template['subtype'],
                    _charset=msg.encoding or settings.DEFAULT_CHARSET
                ), 'unknown/unknown')

        return msg

    return create_multilingual_mail(template_name, subject, context, **kwargs)

    Attempts to create an email that only has a single language, which is
    pulled from the context using get_language.

    If it cannot send the email in the requested language, it will call
    create_multilingual_email to send an email in all the languages that are
    available.

    :param template_name: The template that should be used for this email
    :param subject: The subject of this email
    :param context: The context for the template
    :param kwargs: Any other data that should be passed to the EmailMessage
        constructor
    :return: an EmailMessage
    
Attempts to create an email that only has a single language, which is
pulled from the context using get_language.

If it cannot send the email in the requested language, it will call
create_multilingual_email to send an email in all the languages that are
available.
Attempts to create an email that only has a single language which is pulled from the context using get_language . If it cannot send the email in the requested language it will call create_multilingual_email to send an email in all the languages that are available .
def create_email(template_name: str, subject: str, context: dict,
                 **kwargs) -> EmailMessage:
    _ensure_setup()
    lang = get_language()
    kwargs['headers'] = kwargs['headers'] if 'headers' in kwargs else {}
    kwargs['headers'] = {
        "X-Mailer": get_mailer_name(),
        "Content-Language": lang,
        **kwargs['headers']
    }
    langs = templates[template_name]
    if lang in langs:
        tpls = langs[lang]
        msg = MultiTemplatableEmailMessage(
            subject=_(subject),
            body=False,
            **kwargs
        )
        for template in tpls:
            msg.attach_alternative(
                SafeMIMEText(
                    _text=get_template(template['file']).render({
                        'locale': template['locale'],
                        **context,
                    }),
                    _subtype=template['subtype'],
                    _charset=msg.encoding or settings.DEFAULT_CHARSET
                ), 'unknown/unknown')
        return msg
    return create_multilingual_mail(template_name, subject, context, **kwargs)
def create_email ( template_name : str , subject : str , context : dict , ** kwargs ) -> EmailMessage : _ensure_setup ( ) lang = get_language ( ) kwargs [ 'headers' ] = kwargs [ 'headers' ] if 'headers' in kwargs else { } kwargs [ 'headers' ] = { "X-Mailer" : get_mailer_name ( ) , "Content-Language" : lang , ** kwargs [ 'headers' ] } langs = templates [ template_name ] if lang in langs : tpls = langs [ lang ] msg = MultiTemplatableEmailMessage ( subject = _ ( subject ) , body = False , ** kwargs ) for template in tpls : msg . attach_alternative ( SafeMIMEText ( _text = get_template ( template [ 'file' ] ) . render ( { 'locale' : template [ 'locale' ] , ** context , } ) , _subtype = template [ 'subtype' ] , _charset = msg . encoding or settings . DEFAULT_CHARSET ) , 'unknown/unknown' ) return msg return create_multilingual_mail ( template_name , subject , context , ** kwargs )
Attempts to create an email that only has a single language, which is
pulled from the context using get_language.
Attempts to create an email that only has a single language which is pulled from the context using get_language .
"""
    Attempts to create an email that only has a single language, which is
    pulled from the context using get_language.

    If it cannot send the email in the requested language, it will call
    create_multilingual_email to send an email in all the languages that are
    available.

    :param template_name: The template that should be used for this email
    :param subject: The subject of this email
    :param context: The context for the template
    :param kwargs: Any other data that should be passed to the EmailMessage
        constructor
    :return: an EmailMessage
    """
None
template_name
str
The template that should be used for this email
The template that should be used for this email
subject
str
The subject of this email
The subject of this email
context
dict
The context for the template
The context for the template
kwargs
Any other data that should be passed to the EmailMessage
constructor
Any other data that should be passed to the EmailMessage constructor