You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
import logging
|
|
|
|
from django.core.mail import EmailMultiAlternatives
|
|
from django.template import Context
|
|
from django.template.loader import get_template
|
|
|
|
logger = logging.Logger(__name__)
|
|
|
|
class RequestNotifiable(object):
|
|
MAIL_CATEGORY = 'Request'
|
|
|
|
SLUG_NOTIFICATION = 'notification'
|
|
SLUG_RESPONSE = 'response'
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(RequestNotifiable, self).__init__(*args, **kwargs)
|
|
|
|
def get_mail_template(self, **kwargs):
|
|
return None
|
|
# return MailTemplate.objects.filter(**kwargs).first()
|
|
|
|
def send_request_notification(self, context):
|
|
"""
|
|
:param context
|
|
: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['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__())
|
|
|