Skip to content
Snippets Groups Projects
email.py 784 B
Newer Older
Piotr Gawron's avatar
Piotr Gawron committed
# coding=utf-8

Piotr Gawron's avatar
Piotr Gawron committed
from django.conf import settings
from django.core.mail import send_mail
from django.core.mail import EmailMessage
Piotr Gawron's avatar
Piotr Gawron committed


class EmailSender(object):
Piotr Gawron's avatar
Piotr Gawron committed
    def send_email(self, subject, body, recipients, cc_recipients=[]):
        email_from = getattr(settings, "DEFAULT_FROM_EMAIL", None)
        recipient_list = []
        for recipient in recipients.split(";"):
            recipient_list.append(recipient)
        cc_recipients.append(email_from)

        message = EmailMessage(
            subject,
            body,
            email_from,
            recipient_list,
            cc=cc_recipients
        )
        message.content_subtype = "html"
        message.send()
Piotr Gawron's avatar
Piotr Gawron committed

Piotr Gawron's avatar
Piotr Gawron committed
#        send_mail(subject, "", email_from, recipient_list, cc=cc_recipients, html_message=body)