From a94627b02f8c1e293e34af8bc32aea3b3619b6eb Mon Sep 17 00:00:00 2001 From: Florin Marina Date: Wed, 25 May 2022 15:29:40 +0300 Subject: [PATCH 1/2] Add reply to list support --- lib/mail/Mail.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/mail/Mail.php b/lib/mail/Mail.php index 05a4c417..7414006f 100644 --- a/lib/mail/Mail.php +++ b/lib/mail/Mail.php @@ -78,6 +78,9 @@ class Mail implements \JsonSerializable /** @var $reply_to ReplyTo Email to be use when replied to */ private $reply_to; + /** @var $reply_to_list ReplyToList Email to be use when replied to */ + private $reply_to_list; + /** @var $personalization Personalization[] Messages and their metadata */ private $personalization; @@ -982,6 +985,56 @@ public function getReplyTo() return $this->reply_to; } + /** + * Add the reply to email address to a Mail object + * + * @param $list array + * both of next formats are supported + * 'replytolist' => [ + * [ + * 'email' => 'email1@domain.com', + * 'name' => 'name one', + * ], [ + * 'email' => 'email2@domain.com', + * 'name' => 'name two', + * ], + * ], + * 'replytolist' => [ + * 'email1@domain.com', + * 'email2@domain.com', + * '', + * ], + */ + public function setReplyToList(array $list) + { + foreach ($list as $l) { + if ($l instanceof ReplyTo ) { + $this->reply_to_list[] = $l; + }else{ + if (is_array($l)) { + if (!empty($l) && $l['email'] !== '') { + $this->reply_to_list[] = new ReplyTo($l['email'], $l['name']); + } + }else{ + if ($l !=='') { + $this->reply_to_list[] = new ReplyTo($l); + } + } + } + } + } + + /** + * Retrieve the reply to list to information attached to a Mail object + * + * @return ReplyToList + */ + + public function getReplyToList() + { + return $this->reply_to_list; + } + /** * Add a subject to a Mail object * @@ -1971,6 +2024,7 @@ static function ($value) { )), 'from' => $this->getFrom(), 'reply_to' => $this->getReplyTo(), + 'reply_to_list' => $this->getReplyToList(), 'subject' => $this->getGlobalSubject(), 'content' => $this->getContents(), 'attachments' => $this->getAttachments(), From c868ab1b0b3a5824da84919a0b78d5255b5d717c Mon Sep 17 00:00:00 2001 From: MxFlorin <40028310+MxFlorin@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:10:34 +0300 Subject: [PATCH 2/2] Update Mail.php --- lib/mail/Mail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mail/Mail.php b/lib/mail/Mail.php index 7414006f..5653cf19 100644 --- a/lib/mail/Mail.php +++ b/lib/mail/Mail.php @@ -1010,12 +1010,12 @@ public function setReplyToList(array $list) foreach ($list as $l) { if ($l instanceof ReplyTo ) { $this->reply_to_list[] = $l; - }else{ + } else { if (is_array($l)) { if (!empty($l) && $l['email'] !== '') { $this->reply_to_list[] = new ReplyTo($l['email'], $l['name']); } - }else{ + } else { if ($l !=='') { $this->reply_to_list[] = new ReplyTo($l); }