|
|
|
|
@ -1,7 +1,10 @@ |
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
from django.core.mail import EmailMultiAlternatives |
|
|
|
|
from django.template import Context |
|
|
|
|
from django.template.loader import get_template |
|
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
|
|
|
|
|
|
logger = logging.Logger(__name__) |
|
|
|
|
|
|
|
|
|
class RequestNotifiable(object): |
|
|
|
|
MAIL_CATEGORY = 'Request' |
|
|
|
|
@ -22,8 +25,17 @@ class RequestNotifiable(object): |
|
|
|
|
:param template_path string: |
|
|
|
|
:return None: |
|
|
|
|
""" |
|
|
|
|
body = get_template('emails/html/contact_email_notification.html') |
|
|
|
|
body_text = get_template('emails/txt/contact_email_notification.txt') |
|
|
|
|
|
|
|
|
|
email = EmailMultiAlternatives( |
|
|
|
|
context['subject'],'body',context['from_email'], |
|
|
|
|
context['recipients'],context['bcc'] |
|
|
|
|
context['email']['subject'], |
|
|
|
|
body_text.render(context['email']), |
|
|
|
|
context['from_email'], |
|
|
|
|
context['recipients'] |
|
|
|
|
) |
|
|
|
|
email.attach_alternative(body.render(context['email']),'text/html') |
|
|
|
|
try: |
|
|
|
|
email.send() |
|
|
|
|
except Exception as e: |
|
|
|
|
logger.error(e.__str__()) |
|
|
|
|
|