From acd6fd7dd389622ae07b41b099731d97fdb0f69c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 21 Sep 2020 11:07:34 -0400 Subject: [PATCH] Add expected method MailBuilder->withHeaders - Address https://github.com/friendica/friendica/issues/9250#issuecomment-696055412 --- include/enotify.php | 6 +++--- src/Util/EMailer/MailBuilder.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index 478b034e5..b7fe18a18 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -550,13 +550,13 @@ function notification($params) 'title' => $title, 'body' => $body, 'subject' => $subject, + 'headers' => $emailBuilder->getHeaders(), ]; Hook::callAll('enotify_mail', $datarray); - $builder = DI::emailer() - ->newNotifyMail() - ->addHeaders($datarray['headers']) + $emailBuilder + ->withHeaders($datarray['headers']) ->withRecipient($params['to_email']) ->forUser([ 'uid' => $datarray['uid'], diff --git a/src/Util/EMailer/MailBuilder.php b/src/Util/EMailer/MailBuilder.php index 24190fe4d..38970a612 100644 --- a/src/Util/EMailer/MailBuilder.php +++ b/src/Util/EMailer/MailBuilder.php @@ -159,6 +159,36 @@ abstract class MailBuilder return $this; } + /** + * Returns the current headers + * + * @return string[][] + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Sets the headers + * + * Expected format is + * [ + * 'Header1' => ['value1', 'value2', ...], + * 'Header2' => ['value3', 'value4', ...], + * ... + * ] + * + * @param string[][] $headers + * @return $this + */ + public function withHeaders(array $headers) + { + $this->headers = $headers; + + return $this; + } + /** * Adds a value to a header *