Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inserting HTML fragments in email templates #38093

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/private/Mail/EMailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
9 changes: 9 additions & 0 deletions lib/public/Mail/IEMailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br> in the text will be replaced by new lines in the plain text email
*
Expand Down