Send -bugs and -docs emails from noreply address

Sending from the submitters address runs afoul to DMARC and other
restrictions. Instead, send the email from a defined noreply address.
Instead, add the original submitter to both the Cc and the Reply-To
header, to make sure they receive followups.

Patch by Stephen, minor changes by Magnus
This commit is contained in:
Stephen Frost
2017-12-18 15:59:18 +01:00
committed by Magnus Hagander
parent 48aadf6815
commit dfd46afae4
7 changed files with 15 additions and 6 deletions

View File

@ -133,7 +133,7 @@ def commentform(request, itemid, version, filename):
form = DocCommentForm(request.POST)
if form.is_valid():
send_template_mail(
form.cleaned_data['email'],
settings.DOCSREPORT_NOREPLY_EMAIL,
settings.DOCSREPORT_EMAIL,
'%s' % form.cleaned_data['shortdesc'],
'docs/docsbugmail.txt', {
@ -142,6 +142,8 @@ def commentform(request, itemid, version, filename):
'details': form.cleaned_data['details'],
},
usergenerated=True,
cc=form.cleaned_data['email'],
replyto='%s, %s' % (form.cleaned_data['email'], settings.DOCSREPORT_NOREPLY_EMAIL),
)
return render_to_response('docs/docsbug_completed.html', {
}, NavContext(request, 'docs'))

View File

@ -7,7 +7,7 @@ from email import encoders
from models import QueuedMail
def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, usergenerated=False, cc=None):
def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, usergenerated=False, cc=None, replyto=None):
# attachment format, each is a tuple of (name, mimetype,contents)
# content should be *binary* and not base64 encoded, since we need to
# use the base64 routines from the email library to get a properly
@ -18,6 +18,8 @@ def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, userge
msg['From'] = sender
if cc:
msg['Cc'] = cc
if replyto:
msg['Reply-To'] = replyto
msg['Date'] = formatdate(localtime=True)
msg['Message-ID'] = make_msgid()

View File

@ -24,7 +24,7 @@ def submitbug(request):
bugid = c.fetchall()[0][0]
send_template_mail(
form.cleaned_data['email'],
settings.BUGREPORT_NOREPLY_EMAIL,
settings.BUGREPORT_EMAIL,
'BUG #%s: %s' % (bugid, form.cleaned_data['shortdesc']),
'misc/bugmail.txt',
@ -34,6 +34,7 @@ def submitbug(request):
},
usergenerated=True,
cc=form.cleaned_data['email'],
replyto='%s, %s' % (form.cleaned_data['email'], settings.BUGREPORT_EMAIL),
)
return render_to_response('misc/bug_completed.html', {

View File

@ -148,7 +148,9 @@ NOTIFICATION_FROM="someone@example.com" # Address to send notific
NOREPLY_FROM="someone@example.com" # Address to send unverified messages from
LISTSERVER_EMAIL="someone@example.com" # Address to majordomo
BUGREPORT_EMAIL="someone@example.com" # Address to pgsql-bugs list
BUGREPORT_NOREPLY_EMAIL="someone-noreply@example.com" # Address to no-reply pgsql-bugs address
DOCSREPORT_EMAIL="someone@example.com" # Address to pgsql-docs list
DOCSREPORT_NOREPLY_EMAIL="someone-noreply@example.com" # Address to no-reply pgsql-docs address
FRONTEND_SERVERS=() # A tuple containing the *IP addresses* of all the
# varnish frontend servers in use.
FTP_MASTERS=() # A tuple containing the *IP addresses* of all machines

View File

@ -8,10 +8,10 @@ from pgweb.mailqueue.util import send_simple_mail
from pgweb.util.helpers import template_to_string
import re
def send_template_mail(sender, receiver, subject, templatename, templateattr={}, usergenerated=False, cc=None):
def send_template_mail(sender, receiver, subject, templatename, templateattr={}, usergenerated=False, cc=None, replyto=None):
send_simple_mail(sender, receiver, subject,
template_to_string(templatename, templateattr),
usergenerated=usergenerated, cc=cc)
usergenerated=usergenerated, cc=cc, replyto=replyto)
def get_client_ip(request):
"""

View File

@ -6,5 +6,6 @@
Your documentation comment has been received, and been posted to
the <a href="/list/pgsql-docs/">pgsql-docs</a> mailinglist. It will
show up there as soon as it has cleared the moderator queue.
A copy of the comment has also been sent to your mailbox.
</p>
{%endblock%}

View File

@ -6,6 +6,7 @@
Your bug report has been received, and given id #{{bugid}}. It has been posted
to the <a href="/list/pgsql-bugs/">pgsql-bugs</a>
mailinglist and will show up there as soon as it has cleared the moderator
queue.
queue. A copy of the report has also been sent to your mailbox. If you need
to add any further information to the report, please reply to that mail.
</p>
{%endblock%}