# Path: lkdcourses/mailing/models.py
# class MailLog(models.Model):
#     to = models.ForeignKey("profiles.UserProfile", related_name="mail_profile")
#     type = models.CharField(choices=MAIL_TEMPLATES, max_length=32)
#     sent_at = models.DateTimeField(default=timezone.now)
#     mandrill_response_id = models.CharField(max_length=255, null=True, blank=True)
#     mandrill_status = models.CharField(max_length=255, null=True, blank=True)


from django.core.mail import EmailMessage
from django.conf import settings
from .models import MailLog

    log_type = template_name

    if sent_before_control:
        if mail_is_sent_before(to_profile, log_type):
            return False

    if to_profile.mail_subscription is False:
        return False

    msg = EmailMessage(
        to=[to_profile.email, ]
    )

    msg.template_name = template_name

    if not global_merge_vars:
        global_merge_vars = {}

    msg.global_merge_vars = global_merge_vars

    if merge_vars:
        msg.merge_vars = merge_vars

    msg.subject = subject

    if not from_email:
        from_email = settings.MAILING_FROM_EMAIL

    if not from_name:

# Path: lkdcourses/mailing/models.py
# class MailLog(models.Model):
#     to = models.ForeignKey("profiles.UserProfile", related_name="mail_profile")
#     type = models.CharField(choices=MAIL_TEMPLATES, max_length=32)
#     sent_at = models.DateTimeField(default=timezone.now)
#     mandrill_response_id = models.CharField(max_length=255, null=True, blank=True)
#     mandrill_status = models.CharField(max_length=255, null=True, blank=True)


# Path: lkdcourses/mailing/helpers.py
from django.core.mail import EmailMessage
from django.conf import settings
from .models import MailLog


    log_type = template_name

    if sent_before_control:
        if mail_is_sent_before(to_profile, log_type):
            return False

    if to_profile.mail_subscription is False:
        return False

    msg = EmailMessage(
        to=[to_profile.email, ]
    )

    msg.template_name = template_name

    if not global_merge_vars:
        global_merge_vars = {}

    msg.global_merge_vars = global_merge_vars

    if merge_vars:
        msg.merge_vars = merge_vars

    msg.subject = subject

    if not from_email:
        from_email = settings.MAILING_FROM_EMAIL

    if not from_name:

        from_name = settings.MAILING_FROM_NAME