diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index 40738623c192f..37d934817c798 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -597,6 +597,25 @@ public function addBodyButton(string $text, string $url, $plainText = '') { $this->plainBody .= $url . PHP_EOL; } + /** + * Adds a HTML fragment to the body of the email. Use only for basic HTML fragments and make sure the given HTML is valid, as this can affect the whole email HTML body + * + * @param string $html The HTML fragment to add to the body of the email + * @param string $plainText The plain text alternative version for the HTML fragment + * @since 27.0.0 + */ + public function addHTMLFragment(string $html, string $plainText): void { + if ($this->footerAdded) { + return; + } + + $this->ensureBodyListClosed(); + $this->ensureBodyIsOpened(); + + $this->htmlBody .= $html; + $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; + } + /** * Close the HTML body when it is open */ diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php index ea0fa970c9acd..4de9e62b59212 100644 --- a/lib/public/Mail/IEMailTemplate.php +++ b/lib/public/Mail/IEMailTemplate.php @@ -136,6 +136,15 @@ public function addBodyButtonGroup(string $textLeft, string $urlLeft, string $te */ public function addBodyButton(string $text, string $url, $plainText = ''); + /** + * Adds a HTML fragment to the body of the email. Use only for basic HTML fragments and make sure the given HTML is valid, as this can affect the whole email HTML body + * + * @param string $html The HTML fragment to add to the body of the email + * @param string $plainText The plain text alternative version for the HTML fragment + * @since 27.0.0 + */ + public function addHTMLFragment(string $html, string $plainText): void; + /** * Adds a logo and a text to the footer.
in the text will be replaced by new lines in the plain text email *