djmaze 2020-11-30 10:50:30 +01:00
parent 892c1071f1
commit 13b41b44c0
2 changed files with 14 additions and 19 deletions

View file

@ -1113,7 +1113,6 @@ abstract class HtmlUtils
public static function ConvertHtmlToPlain(string $sText) : string public static function ConvertHtmlToPlain(string $sText) : string
{ {
$sText = \trim(\stripslashes($sText));
$sText = \MailSo\Base\Utils::StripSpaces($sText); $sText = \MailSo\Base\Utils::StripSpaces($sText);
$sText = \preg_replace(array( $sText = \preg_replace(array(

View file

@ -20,12 +20,12 @@ class Message
/** /**
* @var array * @var array
*/ */
private $aHeadersValue; private $aHeadersValue = array();
/** /**
* @var array * @var array
*/ */
private $aAlternativeParts; private $aAlternativeParts = array();
/** /**
* @var AttachmentCollection * @var AttachmentCollection
@ -35,20 +35,16 @@ class Message
/** /**
* @var bool * @var bool
*/ */
private $bAddEmptyTextPart; private $bAddEmptyTextPart = true;
/** /**
* @var bool * @var bool
*/ */
private $bAddDefaultXMailer; private $bAddDefaultXMailer = true;
function __construct() function __construct()
{ {
$this->aHeadersValue = array();
$this->aAlternativeParts = array();
$this->oAttachmentCollection = new AttachmentCollection; $this->oAttachmentCollection = new AttachmentCollection;
$this->bAddEmptyTextPart = true;
$this->bAddDefaultXMailer = true;
} }
public function DoesNotCreateEmptyTextPart() : self public function DoesNotCreateEmptyTextPart() : self
@ -325,16 +321,12 @@ class Message
public function AddPlain(string $sPlain) : self public function AddPlain(string $sPlain) : self
{ {
return $this->AddAlternative( return $this->AddAlternative(Enumerations\MimeType::TEXT_PLAIN, $sPlain);
Enumerations\MimeType::TEXT_PLAIN, trim($sPlain),
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
} }
public function AddHtml(string $sHtml) : self public function AddHtml(string $sHtml) : self
{ {
return $this->AddAlternative( return $this->AddAlternative(Enumerations\MimeType::TEXT_HTML, $sHtml);
Enumerations\MimeType::TEXT_HTML, trim($sHtml),
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
} }
public function AddText(string $sHtmlOrPlainText, bool $bIsHtml = false) : self public function AddText(string $sHtmlOrPlainText, bool $bIsHtml = false) : self
@ -342,10 +334,14 @@ class Message
return $bIsHtml ? $this->AddHtml($sHtmlOrPlainText) : $this->AddPlain($sHtmlOrPlainText); return $bIsHtml ? $this->AddHtml($sHtmlOrPlainText) : $this->AddPlain($sHtmlOrPlainText);
} }
public function AddAlternative(string $sContentType, $mData, string $sContentTransferEncoding = '', array $aCustomContentTypeParams = array()) : self public function AddAlternative(string $sContentType, string $sData) : self
{ {
$this->aAlternativeParts[] = array($sContentType, $mData, $sContentTransferEncoding, $aCustomContentTypeParams); $this->aAlternativeParts[] = array(
$sContentType,
\preg_replace('/\\r?\\n/', Enumerations\Constants::CRLF, \trim($sData)),
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER,
array()
);
return $this; return $this;
} }
@ -531,7 +527,7 @@ class Message
private function createNewMessageSimpleOrAlternativeBody() : Part private function createNewMessageSimpleOrAlternativeBody() : Part
{ {
$oResultPart = null; $oResultPart = null;
if (1 < count($this->aAlternativeParts)) if (1 < \count($this->aAlternativeParts))
{ {
$oResultPart = new Part; $oResultPart = new Part;