15 lines
717 B
Python
15 lines
717 B
Python
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} <compliance@sfconservancy.org>'
|
|
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)
|