Skip to content

Commit

Permalink
setting Auto-Submitted for notification mails
Browse files Browse the repository at this point in the history
uses method from nextcloud/server#35876 if it exists, falling back
setting it via the swift message

Signed-off-by: Bennet Becker <dev@bennet.cc>
  • Loading branch information
bennet0496 authored and susnux committed Oct 18, 2023
1 parent 8738066 commit 6ba198b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\RichObjectStrings\InvalidObjectExeption;
use OCP\RichObjectStrings\IValidator;
Expand Down Expand Up @@ -375,6 +375,12 @@ protected function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime
$message->useTemplate($template);
$message->setFrom([$this->getSenderData('email') => $this->getSenderData('name')]);

if(method_exists($message, 'setAutoSubmitted')){
$message->setAutoSubmitted(\OCP\Mail\AutoSubmittedValue::AUTO_GENERATED);
} else {
$message->getSwiftMessage()->getHeaders()->addTextHeader('Auto-Submitted', 'auto-generated');
}

try {
$this->mailer->send($message);
} catch (\Exception $e) {
Expand Down

0 comments on commit 6ba198b

Please sign in to comment.