Skip to content
Open
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 src/SimpleEmailServiceMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ public function setSubjectCharset($charset) {
return $this;
}

// generate automatically the text version of an HTML email content (Quick n'dirty)
public function setMessageFromHTMLString($html) {

$text=$html;
$LayoutTags = array('span', 'p' ,'div', 'code', 'pre', );

//artificially adds '\n' for tags that are used for layout before been stripped by striptags
foreach ($LayoutTags as $tag) {
$text=str_replace("</$tag>","</$tag>\n", $text);
}
$text=str_replace("<br>","<br>\n", $text);
$text = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$text)));

$this->messagetext = $text;
$this->messagehtml = $html;

return $this;
}

public function setMessageFromString($text, $html = null) {
$this->messagetext = $text;
$this->messagehtml = $html;
Expand Down