summaryrefslogtreecommitdiffstats
path: root/lib/private/Mail
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Mail')
-rw-r--r--lib/private/Mail/Mailer.php3
-rw-r--r--lib/private/Mail/Message.php20
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index d55546769ee..001f7bd75c9 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -93,7 +93,8 @@ class Mailer implements IMailer {
* @return IMessage
*/
public function createMessage(): IMessage {
- return new Message(new \Swift_Message());
+ $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
+ return new Message(new \Swift_Message(), $plainTextOnly);
}
/**
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index 7c7ecae8578..8a13e2c108c 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -39,12 +39,12 @@ use Swift_Message;
class Message implements IMessage {
/** @var Swift_Message */
private $swiftMessage;
+ /** @var bool */
+ private $plainTextOnly;
- /**
- * @param Swift_Message $swiftMessage
- */
- public function __construct(Swift_Message $swiftMessage) {
+ public function __construct(Swift_Message $swiftMessage, bool $plainTextOnly) {
$this->swiftMessage = $swiftMessage;
+ $this->plainTextOnly = $plainTextOnly;
}
/**
@@ -246,7 +246,9 @@ class Message implements IMessage {
* @return $this
*/
public function setHtmlBody($body) {
- $this->swiftMessage->addPart($body, 'text/html');
+ if (!$this->plainTextOnly) {
+ $this->swiftMessage->addPart($body, 'text/html');
+ }
return $this;
}
@@ -264,7 +266,9 @@ class Message implements IMessage {
* @return $this
*/
public function setBody($body, $contentType) {
- $this->swiftMessage->setBody($body, $contentType);
+ if (!$this->plainTextOnly || $contentType !== 'text/html') {
+ $this->swiftMessage->setBody($body, $contentType);
+ }
return $this;
}
@@ -275,7 +279,9 @@ class Message implements IMessage {
public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
$this->setSubject($emailTemplate->renderSubject());
$this->setPlainBody($emailTemplate->renderText());
- $this->setHtmlBody($emailTemplate->renderHtml());
+ if (!$this->plainTextOnly) {
+ $this->setHtmlBody($emailTemplate->renderHtml());
+ }
return $this;
}
}