Add email send reasons

This commit is contained in:
rubenwardy
2020-12-05 19:52:02 +00:00
parent 3efda30b98
commit 5fe3b0b459
7 changed files with 42 additions and 17 deletions

View File

@@ -41,17 +41,30 @@ def sendVerifyEmail(newEmail, token):
msg.html = render_template("emails/verify.html", token=token)
mail.send(msg)
@celery.task()
def sendEmailRaw(to, subject, text, html=None):
def send_email_with_reason(to, subject, text, html, reason):
from flask_mail import Message
msg = Message(subject, recipients=to)
msg.body = text
html = html or text
msg.html = render_template("emails/base.html", subject=subject, content=html)
msg.html = render_template("emails/base.html", subject=subject, content=html, reason=reason)
mail.send(msg)
@celery.task()
def send_user_email(to, subject, text, html=None):
return send_email_with_reason(to, subject, text, html,
"You are receiving this email because you are a registered user of ContentDB.")
@celery.task()
def send_anon_email(to, subject, text, html=None):
return send_email_with_reason(to, subject, text, html,
"You are receiving this email because someone (hopefully you) entered your email address as a user's email.")
def sendNotificationEmail(notification):
msg = Message(notification.title, recipients=[notification.user.email])