Send -bugs and -docs emails from noreply address
authorStephen Frost <sfrost@snowman.net>
Mon, 18 Dec 2017 14:59:18 +0000 (15:59 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 18 Dec 2017 14:59:18 +0000 (15:59 +0100)
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

pgweb/docs/views.py
pgweb/mailqueue/util.py
pgweb/misc/views.py
pgweb/settings.py
pgweb/util/misc.py
templates/docs/docsbug_completed.html
templates/misc/bug_completed.html

index a2c0c9143fb828faae0c9ed65317f962aae3083e..c961e26ee4963ce14afb605341eaf6bdc33d46f3 100644 (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'))
index aac28be79455426a83e0993ddf37a29f4eea06f3..1c3879cb02547d8e07bea30242699b7f7b56fbac 100644 (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()
 
index 261f195af15e2087cb8ab54763070e8c8aabf3c5..f340e7783022f7fe20d968f8c4a3fab39778097d 100644 (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', {
index 7deba10ba1042ac4c561da2fc12688ffa7d8685e..2fd6a1068b7dcd39e7139d52a667ff90ab92176e 100644 (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
index 3f436c850bc5f5309231c5067d7e49499beae8c9..b9f1bf166062f2b64a1f34e1708cd38d9bccd688 100644 (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):
        """
index b1a910fdcf581384049a69a1c26a7260fbb07f72..f967600c04782a41f8d219dec9ba50c39a8d310a 100644 (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%}
index 2f9f86bd1e63e1d528707c47f5b831310a93276d..b36c58d521525a514bb6bd55608da62bcf765ec8 100644 (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%}