Move some message checks to MailSo\Mime\Message

This commit is contained in:
the-djmaze 2023-02-15 12:03:51 +01:00
parent d629f42e4c
commit 353fdda3e5
2 changed files with 26 additions and 40 deletions

View file

@ -179,16 +179,19 @@ class Message extends Part
public function SetInReplyTo(string $sInReplyTo) : self
{
$this->aHeadersValue[Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
$sInReplyTo = \trim($sInReplyTo);
if (\strlen($sInReplyTo)) {
$this->aHeadersValue[Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
}
return $this;
}
public function SetReferences(string $sReferences) : self
{
$this->aHeadersValue[Enumerations\Header::REFERENCES] =
\MailSo\Base\Utils::StripSpaces($sReferences);
$sReferences = \MailSo\Base\Utils::StripSpaces($sReferences);
if (\strlen($sReferences)) {
$this->aHeadersValue[Enumerations\Header::REFERENCES] = $sReferences;
}
return $this;
}
@ -239,8 +242,9 @@ class Message extends Part
public function SetTo(EmailCollection $oEmails) : self
{
$this->aHeadersValue[Enumerations\Header::TO_] = $oEmails;
if ($oEmails->count()) {
$this->aHeadersValue[Enumerations\Header::TO_] = $oEmails;
}
return $this;
}
@ -253,22 +257,25 @@ class Message extends Part
public function SetReplyTo(EmailCollection $oEmails) : self
{
$this->aHeadersValue[Enumerations\Header::REPLY_TO] = $oEmails;
if ($oEmails->count()) {
$this->aHeadersValue[Enumerations\Header::REPLY_TO] = $oEmails;
}
return $this;
}
public function SetCc(EmailCollection $oEmails) : self
{
$this->aHeadersValue[Enumerations\Header::CC] = $oEmails;
if ($oEmails->count()) {
$this->aHeadersValue[Enumerations\Header::CC] = $oEmails;
}
return $this;
}
public function SetBcc(EmailCollection $oEmails) : self
{
$this->aHeadersValue[Enumerations\Header::BCC] = $oEmails;
if ($oEmails->count()) {
$this->aHeadersValue[Enumerations\Header::BCC] = $oEmails;
}
return $this;
}

View file

@ -989,10 +989,7 @@ trait Messages
$oFrom = $oMessage->GetFrom();
$oMessage->RegenerateMessageId($oFrom ? $oFrom->GetDomain() : '');
$oReplyTo = new \MailSo\Mime\EmailCollection($this->GetActionParam('replyTo', ''));
if ($oReplyTo->count()) {
$oMessage->SetReplyTo($oReplyTo);
}
$oMessage->SetReplyTo(new \MailSo\Mime\EmailCollection($this->GetActionParam('replyTo', '')));
if (!empty($this->GetActionParam('readReceiptRequest', 0))) {
// Read Receipts Reference Main Account Email, Not Identities #147
@ -1010,35 +1007,17 @@ trait Messages
$oMessage->SetSubject($this->GetActionParam('subject', ''));
$oToEmails = new \MailSo\Mime\EmailCollection($this->GetActionParam('to', ''));
if ($oToEmails->count()) {
$oMessage->SetTo($oToEmails);
}
$oCcEmails = new \MailSo\Mime\EmailCollection($this->GetActionParam('cc', ''));
if ($oCcEmails->count()) {
$oMessage->SetCc($oCcEmails);
}
$oBccEmails = new \MailSo\Mime\EmailCollection($this->GetActionParam('bcc', ''));
if ($oBccEmails->count()) {
$oMessage->SetBcc($oBccEmails);
}
$oMessage->SetTo(new \MailSo\Mime\EmailCollection($this->GetActionParam('to', '')));
$oMessage->SetCc(new \MailSo\Mime\EmailCollection($this->GetActionParam('cc', '')));
$oMessage->SetBcc(new \MailSo\Mime\EmailCollection($this->GetActionParam('bcc', '')));
$aDraftInfo = $this->GetActionParam('draftInfo', null);
if ($bWithDraftInfo && \is_array($aDraftInfo) && !empty($aDraftInfo[0]) && !empty($aDraftInfo[1]) && !empty($aDraftInfo[2])) {
$oMessage->SetDraftInfo($aDraftInfo[0], $aDraftInfo[1], $aDraftInfo[2]);
}
$sInReplyTo = $this->GetActionParam('inReplyTo', '');
if (\strlen($sInReplyTo)) {
$oMessage->SetInReplyTo($sInReplyTo);
}
$sReferences = $this->GetActionParam('references', '');
if (\strlen($sReferences)) {
$oMessage->SetReferences($sReferences);
}
$oMessage->SetInReplyTo($this->GetActionParam('inReplyTo', ''));
$oMessage->SetReferences($this->GetActionParam('references', ''));
$aFoundCids = array();
$aFoundDataURL = array();