Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Discourage automatic replies to Synapse's emails #13957

Merged
merged 4 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13957.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ask mail servers receiving emails from Synapse to not send automatic reply (e.g. out-of-office responses).
14 changes: 14 additions & 0 deletions synapse/handlers/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ async def send_email(
multipart_msg["To"] = email_address
multipart_msg["Date"] = email.utils.formatdate()
multipart_msg["Message-ID"] = email.utils.make_msgid()
# Discourage automatic responses to Synapse's emails.
# Per RFC 3834, automatic responses should not be sent if the "Auto-Submitted"
# header is present with any value other than "no". See
# https://www.rfc-editor.org/rfc/rfc3834.html#section-5.1
multipart_msg["Auto-Submitted"] = "auto-generated"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# We also include a barely-documented Microsoft-Exchange specific header.
# The best reference I could find was
# https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcmail/ced68690-498a-4567-9d14-5c01f974d8b1
# which seems to suggest it can take the value "All" to mean "suppress all
# auto-replies", or a comma separated list of auto-reply classes to suppress.
# The following stack overflow question has a little more context:
# https://stackoverflow.com/a/25324691/5252017
# https://stackoverflow.com/a/61646381/5252017
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved
multipart_msg["X-Auto-Response-Suppress"] = "All"
clokep marked this conversation as resolved.
Show resolved Hide resolved
multipart_msg.attach(text_part)
multipart_msg.attach(html_part)

Expand Down