# Path: src/contrib/email_from_template/utils.py
# def get_render_method():
#     return from_dotted_path(app_settings.EMAIL_RENDER_METHOD)
# 
# def get_context_processors():
#     return [from_dotted_path(x) for x in app_settings.EMAIL_CONTEXT_PROCESSORS]


from django.conf import settings
from django.template import Context
from django.core.mail import get_connection
from django.core.mail.message import EmailMultiAlternatives
from .utils import get_render_method, get_context_processors


def send_mail(recipient_list, template, context=None, from_email=None, send_mail=True, *args, **kwargs):
    """
    Wrapper around ``django.core.mail.send_mail`` that generates the subject
    and message body from a template.

    Usage::

        >>> from email_from_template import send_mail
        >>> send_mail([user.email], 'path/to/my_email.email', {
            'a': 1,
            'user': user,
        })

    path/to/my_email.email::

        {% extends email_from_template %}

        {% block subject %}
        Hi {{ user.username }}
        {% endblock %}

        {% block body %}
        Hi {{ user.username }}.
        Did you know that a = {{ a }} ?
        {% endblock %}
    """

    context = Context(context)

# Path: src/contrib/email_from_template/utils.py
# def get_render_method():
#     return from_dotted_path(app_settings.EMAIL_RENDER_METHOD)
# 
# def get_context_processors():
#     return [from_dotted_path(x) for x in app_settings.EMAIL_CONTEXT_PROCESSORS]


# Path: src/contrib/email_from_template/send_mail.py
from django.conf import settings
from django.template import Context
from django.core.mail import get_connection
from django.core.mail.message import EmailMultiAlternatives
from .utils import get_render_method, get_context_processors



def send_mail(recipient_list, template, context=None, from_email=None, send_mail=True, *args, **kwargs):
    """
    Wrapper around ``django.core.mail.send_mail`` that generates the subject
    and message body from a template.

    Usage::

        >>> from email_from_template import send_mail
        >>> send_mail([user.email], 'path/to/my_email.email', {
            'a': 1,
            'user': user,
        })

    path/to/my_email.email::

        {% extends email_from_template %}

        {% block subject %}
        Hi {{ user.username }}
        {% endblock %}

        {% block body %}
        Hi {{ user.username }}.
        Did you know that a = {{ a }} ?
        {% endblock %}
    """

    context = Context(context)

    for fn in get_context_processors():