mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-01-31 10:29:15 +01:00
ADDED: Possibility to accept extra headers when sending emails
This commit is contained in:
parent
d091a16002
commit
b4c6c169c2
@ -22,7 +22,7 @@ logger = logging.getLogger('helpdesk')
|
|||||||
|
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
|
|
||||||
def send_templated_mail(template_name, email_context, recipients, sender=None, bcc=None, fail_silently=False, files=None):
|
def send_templated_mail(template_name, email_context, recipients, sender=None, bcc=None, fail_silently=False, files=None, extra_headers={}):
|
||||||
"""
|
"""
|
||||||
send_templated_mail() is a warpper around Django's e-mail routines that
|
send_templated_mail() is a warpper around Django's e-mail routines that
|
||||||
allows us to easily send multipart (text/plain & text/html) e-mails using
|
allows us to easily send multipart (text/plain & text/html) e-mails using
|
||||||
@ -82,7 +82,7 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
|
|||||||
t = EmailTemplate.objects.get(template_name__iexact=template_name, locale__isnull=True)
|
t = EmailTemplate.objects.get(template_name__iexact=template_name, locale__isnull=True)
|
||||||
except EmailTemplate.DoesNotExist:
|
except EmailTemplate.DoesNotExist:
|
||||||
logger.warning('template "%s" does not exist, no mail sent' %
|
logger.warning('template "%s" does not exist, no mail sent' %
|
||||||
template_name)
|
template_name)
|
||||||
return # just ignore if template doesn't exist
|
return # just ignore if template doesn't exist
|
||||||
|
|
||||||
if not sender:
|
if not sender:
|
||||||
@ -133,7 +133,9 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
|
|||||||
text_part,
|
text_part,
|
||||||
sender,
|
sender,
|
||||||
recipients,
|
recipients,
|
||||||
bcc=bcc)
|
bcc=bcc,
|
||||||
|
headers=extra_headers,
|
||||||
|
)
|
||||||
msg.attach_alternative(html_part, "text/html")
|
msg.attach_alternative(html_part, "text/html")
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
|
Loading…
Reference in New Issue
Block a user