From 199fce8038086dca874029114690bd0ec68aab37 Mon Sep 17 00:00:00 2001 From: slater0013 <49311455+slater0013@users.noreply.github.com> Date: Fri, 28 May 2021 11:08:05 +0200 Subject: [PATCH] Auto-Submitted mail header added Auto-Submitted header should be added to every mail sent by an automatic system, such as CRON jobs, etc. Auto-Reply systems should NOT reply when this header is set to 'auto-generated'. --- lib/private/Mail/Mailer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index e31784db58..4862826e40 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -188,6 +188,10 @@ class Mailer implements IMailer { if (empty($message->getFrom())) { $message->setFrom([\OCP\Util::getDefaultEmailAddress('no-reply') => $this->defaults->getName()]); } + + // Add Auto-Submitted mail header. 'auto-generated' value should be set when email is sent by a script such as CRON jobs, etc. + $headers = $message->getSwiftMessage()->getHeaders(); + $headers->addTextHeader('Auto-Submitted', 'auto-generated'); $failedRecipients = [];