diff --git a/conservancy/usethesource/emails.py b/conservancy/usethesource/emails.py new file mode 100644 index 0000000000000000000000000000000000000000..8fde9d6f261dfae3fe48bca30c86f2550ea385ed --- /dev/null +++ b/conservancy/usethesource/emails.py @@ -0,0 +1,15 @@ +from django.core.mail import EmailMessage + + +def make_comment_email(comment): + subject = f'Re: {comment.candidate.name}' + signature = comment.user.get_full_name() or comment.user.username + sender = f'{signature} ' + to = ['nutbush@lists.sfconservancy.org'] + body = f'{comment.message}\n\n--\n{signature}' + headers = {'Message-ID': comment.email_message_id} + if in_reply_to := comment.in_reply_to(): + # From my testing, both "In-Reply-To" and "References" headers trigger + # email threading in Thunderbind. Sticking to "In-Reply-To" for now. + headers['In-Reply-To'] = in_reply_to + return EmailMessage(subject, body, sender, to, headers=headers)