From 0aa96508ec8a30dbd47eb5f5d31eabeabfc3d9a9 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 15 Jul 2014 12:57:17 +0200 Subject: [PATCH] Include name of cf username causing emails to be sent in the headers --- pgcommitfest/commitfest/views.py | 3 ++- pgcommitfest/mailqueue/util.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index 0230c41..b5d6af3 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -279,6 +279,7 @@ def comment(request, cfid, patchid, what): msg['From'] = "%s %s <%s>" % (request.user.first_name, request.user.last_name, request.user.email) msg['Date'] = formatdate(localtime=True) msg['User-Agent'] = 'pgcommitfest' + msg['X-cfsender'] = request.user.username msg['In-Reply-To'] = '<%s>' % form.respid # We just add the "top" messageid and the one we're responding to. # This along with in-reply-to should indicate clearly enough where @@ -464,7 +465,7 @@ def send_email(request, cfid): recipients = User.objects.filter(q).distinct() for r in recipients: - send_simple_mail(request.user.email, r.email, form.cleaned_data['subject'], form.cleaned_data['body']) + send_simple_mail(request.user.email, r.email, form.cleaned_data['subject'], form.cleaned_data['body'], request.user.username) messages.add_message(request, messages.INFO, "Sent email to %s" % r.email) return HttpResponseRedirect('..') else: diff --git a/pgcommitfest/mailqueue/util.py b/pgcommitfest/mailqueue/util.py index f38272c..60afd5d 100644 --- a/pgcommitfest/mailqueue/util.py +++ b/pgcommitfest/mailqueue/util.py @@ -6,7 +6,7 @@ from email import encoders from models import QueuedMail -def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None): +def send_simple_mail(sender, receiver, subject, msgtxt, sending_username, attachments=None): # attachment format, each is a tuple of (name, mimetype,contents) # content should already be base64 encoded msg = MIMEMultipart() @@ -14,6 +14,8 @@ def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None): msg['To'] = receiver msg['From'] = sender msg['Date'] = formatdate(localtime=True) + msg['User-Agent'] = 'pgcommitfest' + msg['X-cfsender'] = sending_username msg.attach(MIMEText(msgtxt, _charset='utf-8')) -- 2.39.5