Private
Public Access
1
0

adding bcc

This commit is contained in:
Sander Roosendaal
2020-06-20 12:09:43 +02:00
parent 467e59ff3b
commit cbed58e0ca
2 changed files with 15 additions and 8 deletions

View File

@@ -53,7 +53,7 @@ from django.contrib.staticfiles import finders
def textify(html):
# Remove html tags and continuous whitespaces
# Remove html tags and continuous whitespaces
text_only = re.sub('[ \t]+', ' ', strip_tags(html))
# Strip single spaces in the beginning of each line
return text_only.replace('\n ', '\n').strip()
@@ -61,7 +61,7 @@ def textify(html):
def htmlstripnobr(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return safe_html
def htmlstrip(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return newlinetobr(safe_html)
@@ -80,11 +80,18 @@ def send_template_email(from_email,to_email,subject,
text_content = textify(html_content)
# html_content = newlinetobr(html_content)
if 'cc' in kwargs:
print(kwargs['bcc'])
if 'bcc' in kwargs and 'cc' in kwargs:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,cc=kwargs['cc'],
bcc=kwargs['bcc'])
elif 'bcc' in kwargs:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,bcc=kwargs['bcc'])
elif 'cc' in kwargs:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,cc=kwargs['cc'])
else:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
msg.attach_alternative(html_content, "text/html")
if 'attach_file' in kwargs:
@@ -106,8 +113,8 @@ def send_template_email(from_email,to_email,subject,
else:
emailbounced = False
if not emailbounced:
res = msg.send()
else: