Skip to content

Commit c1f5c9e

Browse files
Xammietaylorotwell
andauthored
[9.x] Add raw content property for mailables (#44703)
* Add raw mailable content property * Fix constructor signature * Fixed style * formatting Co-authored-by: Taylor Otwell <[email protected]>
1 parent 23195b4 commit c1f5c9e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/Illuminate/Mail/Mailable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,10 @@ private function ensureContentIsHydrated()
16551655
$this->markdown($content->markdown);
16561656
}
16571657

1658+
if ($content->htmlString) {
1659+
$this->html($content->htmlString);
1660+
}
1661+
16581662
foreach ($content->with as $key => $value) {
16591663
$this->with($key, $value);
16601664
}

src/Illuminate/Mail/Mailables/Content.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class Content
3838
*/
3939
public $markdown;
4040

41+
/**
42+
* The pre-rendered HTML of the message.
43+
*
44+
* @var string|null
45+
*/
46+
public $htmlString;
47+
4148
/**
4249
* The message's view data.
4350
*
@@ -53,16 +60,18 @@ class Content
5360
* @param string|null $text
5461
* @param string|null $markdown
5562
* @param array $with
63+
* @param string|null $htmlString
5664
*
5765
* @named-arguments-supported
5866
*/
59-
public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = [])
67+
public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = [], string $htmlString = null)
6068
{
6169
$this->view = $view;
6270
$this->html = $html;
6371
$this->text = $text;
6472
$this->markdown = $markdown;
6573
$this->with = $with;
74+
$this->htmlString = $htmlString;
6675
}
6776

6877
/**
@@ -115,6 +124,19 @@ public function markdown(string $view)
115124
return $this;
116125
}
117126

127+
/**
128+
* Set the pre-rendered HTML for the message.
129+
*
130+
* @param string $html
131+
* @return $this
132+
*/
133+
public function htmlString(string $html)
134+
{
135+
$this->htmlString = $html;
136+
137+
return $this;
138+
}
139+
118140
/**
119141
* Add a piece of view data to the message.
120142
*

0 commit comments

Comments
 (0)