def review_notification(email_url, user_email, context, mail, copy_to_staffs=False, copy_to_gatekeeper=False): # pylint: disable=too-many-arguments
"""Compose the message and send the email."""
if config.CLAIMANT_EMAIL_NOTIFICATION and email_url is not None:
# Generate message
flatemail = FlatPage.objects.get(url=email_url)
template = Template(flatemail.content)
context.update({
"notes": mail.justification,
"protocol": "https",
"site": Site.objects.get(id=SITE_ID),
"FELLOWS_MANAGEMENT_EMAIL": config.FELLOWS_MANAGEMENT_EMAIL,
})
context = Context(context)
html = template.render(context)
plain_text = html2text(html)
mail.justification = plain_text
# Email to claimant
msg = EmailMultiAlternatives(
flatemail.title,
plain_text,
mail.sender.email,
user_email,
cc=[config.WEBSITE_GATEKEEPER_EMAIL] if copy_to_gatekeeper else None,
bcc=ast.literal_eval(config.STAFFS_EMAIL) if copy_to_staffs else None,
reply_to=[config.FELLOWS_MANAGEMENT_EMAIL]
)
msg.attach_alternative(html, "text/html")
msg.send(fail_silently=False)
# Every email is archived in the database
mail.save()
评论列表
文章目录