Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #157 from markokeeffe/raw-message-split
Browse files Browse the repository at this point in the history
Allow raw message to have separate html/text parts
  • Loading branch information
Bogardo authored Oct 16, 2019
2 parents cbda1b6 + acb22f1 commit 86aca9f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,27 @@ protected function setTextBody($view, array $data)
*/
protected function setRawBody($view)
{
$this->message->builder()->setHtmlBody($view);
$this->message->builder()->setTextBody(strip_tags($view, '<a>'));
// If raw body is a string, set HTML and use strip_tags to generate text content
if (is_string($view)) {
$this->message->builder()->setHtmlBody($view);
$this->message->builder()->setTextBody(strip_tags($view, '<a>'));
} elseif (is_array($view) && isset($view[0])) {
// Get HTML from first element of view array
$this->message->builder()->setHtmlBody($view[0]);
if (isset($view[1])) {
// Get text content if present in second element
$this->message->builder()->setTextBody($view[1]);
}
} elseif (is_array($view)) {
// Set HTML content from view array
if (isset($view['html'])) {
$this->message->builder()->setHtmlBody($view['html']);
}
// Set text content from view array
if (isset($view['text'])) {
$this->message->builder()->setTextBody($view['text']);
}
}
}

/**
Expand Down

0 comments on commit 86aca9f

Please sign in to comment.