mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-10 00:42:06 +00:00
Set headers for no auto response on most emails
Most of our auto-generated emails should not ask for auto replies (like out of office messages or in particular, "held for moderation" notices from our own list server), so set this header by default, and also the header indicating if it's an auto submitted/auto replied message. Specifically allow auto replies on moderation notices, since that's a case where it might be really interesting for the moderator to see for example an out of office message. At least for now that seems like a good idea.
This commit is contained in:
@ -15,7 +15,7 @@ def _encoded_email_header(name, email):
|
||||
return email
|
||||
|
||||
|
||||
def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, usergenerated=False, cc=None, replyto=None, sendername=None, receivername=None, messageid=None):
|
||||
def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, usergenerated=False, cc=None, replyto=None, sendername=None, receivername=None, messageid=None, suppress_auto_replies=True, is_auto_reply=False):
|
||||
# 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
|
||||
@ -33,6 +33,16 @@ def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, userge
|
||||
msg['Message-ID'] = messageid
|
||||
else:
|
||||
msg['Message-ID'] = make_msgid()
|
||||
if suppress_auto_replies:
|
||||
# Do our best to set some headers to indicate that auto-replies like out of office
|
||||
# messages should not be sent to this email.
|
||||
msg['X-Auto-Response-Suppress'] = 'All'
|
||||
|
||||
# Is this email auto-generated or auto-replied?
|
||||
if is_auto_reply:
|
||||
msg['Auto-Submitted'] = 'auto-replied'
|
||||
elif not usergenerated:
|
||||
msg['Auto-Submitted'] = 'auto-generated'
|
||||
|
||||
msg.attach(MIMEText(msgtxt, _charset='utf-8'))
|
||||
|
||||
|
Reference in New Issue
Block a user