diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 4e4873508e8d..9ccf6ec53868 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -1655,6 +1655,10 @@ private function ensureContentIsHydrated() $this->markdown($content->markdown); } + if ($content->htmlString) { + $this->html($content->htmlString); + } + foreach ($content->with as $key => $value) { $this->with($key, $value); } diff --git a/src/Illuminate/Mail/Mailables/Content.php b/src/Illuminate/Mail/Mailables/Content.php index f0f00e3662af..319cfefa744c 100644 --- a/src/Illuminate/Mail/Mailables/Content.php +++ b/src/Illuminate/Mail/Mailables/Content.php @@ -38,6 +38,13 @@ class Content */ public $markdown; + /** + * The pre-rendered HTML of the message. + * + * @var string|null + */ + public $htmlString; + /** * The message's view data. * @@ -53,16 +60,18 @@ class Content * @param string|null $text * @param string|null $markdown * @param array $with + * @param string|null $htmlString * * @named-arguments-supported */ - public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = []) + public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = [], string $htmlString = null) { $this->view = $view; $this->html = $html; $this->text = $text; $this->markdown = $markdown; $this->with = $with; + $this->htmlString = $htmlString; } /** @@ -115,6 +124,19 @@ public function markdown(string $view) return $this; } + /** + * Set the pre-rendered HTML for the message. + * + * @param string $html + * @return $this + */ + public function htmlString(string $html) + { + $this->htmlString = $html; + + return $this; + } + /** * Add a piece of view data to the message. *