From 7efc07d4e828c831a1c44b194c13fdb1bed80c9c Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 29 Sep 2022 23:08:51 +0100 Subject: [PATCH 1/4] Emails: send `X-Auto-Respond-Suppress: All` header --- synapse/handlers/send_email.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/synapse/handlers/send_email.py b/synapse/handlers/send_email.py index e2844799e886..585b7702e5bf 100644 --- a/synapse/handlers/send_email.py +++ b/synapse/handlers/send_email.py @@ -187,6 +187,21 @@ async def send_email( multipart_msg["To"] = email_address multipart_msg["Date"] = email.utils.formatdate() multipart_msg["Message-ID"] = email.utils.make_msgid() + # A Microsoft Exchange user can configure an automatic reply (e.g. "I'm out of + # office until the 1st of January") to be sent to all incoming emails for a + # duration. But Exchange will NOT generate an automatic reply if the incoming + # message includes the following obscure, non-standard(?) and barely documented + # header with an appropriate value. The header does NOT mark the email as being + # auto-generated; it's more of a "don't reply to me" marker. + # + # 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 + multipart_msg["X-Auto-Response-Suppress"] = "All" multipart_msg.attach(text_part) multipart_msg.attach(html_part) From 606c07821e89ead4315e28cc3cc3fc53aab09d24 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 29 Sep 2022 23:15:08 +0100 Subject: [PATCH 2/4] Changelog --- changelog.d/13957.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13957.feature diff --git a/changelog.d/13957.feature b/changelog.d/13957.feature new file mode 100644 index 000000000000..4080147357ee --- /dev/null +++ b/changelog.d/13957.feature @@ -0,0 +1 @@ +Ask mail servers receiving emails from Synapse to not send automatic reply (e.g. out-of-office responses). From 974b020d54d573c18a2efe74c914f16d217e9ced Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 30 Sep 2022 13:17:12 +0100 Subject: [PATCH 3/4] Trim comment; include Auto-Submitted header --- synapse/handlers/send_email.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/synapse/handlers/send_email.py b/synapse/handlers/send_email.py index 585b7702e5bf..11ce715d9a50 100644 --- a/synapse/handlers/send_email.py +++ b/synapse/handlers/send_email.py @@ -187,13 +187,12 @@ async def send_email( multipart_msg["To"] = email_address multipart_msg["Date"] = email.utils.formatdate() multipart_msg["Message-ID"] = email.utils.make_msgid() - # A Microsoft Exchange user can configure an automatic reply (e.g. "I'm out of - # office until the 1st of January") to be sent to all incoming emails for a - # duration. But Exchange will NOT generate an automatic reply if the incoming - # message includes the following obscure, non-standard(?) and barely documented - # header with an appropriate value. The header does NOT mark the email as being - # auto-generated; it's more of a "don't reply to me" marker. - # + # 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" + # 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 From 4f4c6c6014cfe7f685aceef97d5d8fe109064ea5 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 30 Sep 2022 13:47:03 +0100 Subject: [PATCH 4/4] More confident comment Co-authored-by: Patrick Cloke --- synapse/handlers/send_email.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/synapse/handlers/send_email.py b/synapse/handlers/send_email.py index 11ce715d9a50..804cc6e81e00 100644 --- a/synapse/handlers/send_email.py +++ b/synapse/handlers/send_email.py @@ -192,11 +192,10 @@ async def send_email( # 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" - # We also include a barely-documented Microsoft-Exchange specific header. - # The best reference I could find was + # Also include a Microsoft-Exchange specific header: # 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. + # which suggests it can take the value "All" to "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