summaryrefslogtreecommitdiffstats
path: root/lib/private/Mail
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Mail')
-rw-r--r--lib/private/Mail/Message.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index d074befcae4..417b64d0f3a 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -307,18 +307,23 @@ class Message implements IMessage {
* Add the Auto-Submitted header to the email, preventing most automated
* responses to automated messages.
*
- * @param string $value (one of AutoSubmittedValue::NO, AutoSubmittedValue::AUTO_GENERATED, AutoSubmittedValue::AUTO_REPLIED)
+ * @param AutoSubmittedValue::* $value (one of AutoSubmittedValue::NO, AutoSubmittedValue::AUTO_GENERATED, AutoSubmittedValue::AUTO_REPLIED)
* @return $this
*/
public function setAutoSubmitted(string $value): IMessage {
$headers = $this->swiftMessage->getHeaders();
- if($headers->has('Auto-Submitted')) {
- $auto_submitted = $headers->get('Auto-Submitted');
- $auto_submitted->setValue($value);
- } else {
- $headers->addTextHeader('Auto-Submitted', $value);
+
+ if ($headers->has('Auto-Submitted')) {
+ // if the header already exsists, remove it.
+ // the value can be modified with some implementations
+ // of the interface \Swift_Mime_Header, however the
+ // interface doesn't, and this makes the static-code
+ // analysis unhappy.
+ $headers->remove('Auto-Submitted');
}
+ $headers->addTextHeader('Auto-Submitted', $value);
+
return $this;
}