diff --git a/include/enotify.php b/include/enotify.php index 9a3e2b0668..9016249a5b 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -502,7 +502,7 @@ function notification($params) Hook::callAll('enotify_mail', $datarray); $builder = DI::emailer() - ->newNotifyMail($l10n) + ->newNotifyMail() ->addHeaders($datarray['headers']) ->withRecipient($params['to_email']) ->forUser($datarray['uid']) diff --git a/src/Util/EMailer/NotifyMailBuilder.php b/src/Util/EMailer/NotifyMailBuilder.php index ca2add0cac..d571e87422 100644 --- a/src/Util/EMailer/NotifyMailBuilder.php +++ b/src/Util/EMailer/NotifyMailBuilder.php @@ -13,8 +13,18 @@ use Friendica\Network\HTTPException\InternalServerErrorException; /** * Builder for notification emails (notification, source, links, ...) */ -class NotifyMailBuilder extends SystemMailBuilder +class NotifyMailBuilder extends MailBuilder { + /** @var string */ + protected $subject; + /** @var string */ + protected $preamble; + /** @var string */ + protected $body; + + /** @var string */ + protected $siteAdmin; + /** @var bool */ private $contentAllowed = true; /** @var string */ @@ -42,7 +52,16 @@ class NotifyMailBuilder extends SystemMailBuilder public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config, string $siteEmailAddress, string $siteName) { - parent::__construct($l10n, $baseUrl, $config, $siteEmailAddress, $siteName); + parent::__construct($l10n, $baseUrl, $config); + + if ($this->config->get('config', 'admin_name')) { + $this->siteAdmin = $l10n->t('%1$s, %2$s Administrator', $this->config->get('config', 'admin_name'), $siteName); + } else { + $this->siteAdmin = $l10n->t('%s Administrator', $siteName); + } + + // Set the system wide site address/name as sender (default for system mails) + $this->withSender($siteName, $siteEmailAddress, $siteEmailAddress); // check whether sending post content in email notifications is allowed $this->contentAllowed = $this->config->get('system', 'enotify_no_content'); @@ -60,9 +79,16 @@ class NotifyMailBuilder extends SystemMailBuilder */ public function withNotification(string $subject, string $preamble, string $title, string $body = null) { - $this->title = stripslashes($title); + if (!isset($body)) { + $body = $preamble; + } - return $this->withMessage($subject, $preamble, $body); + $this->title = stripslashes($title); + $this->subject = $subject; + $this->preamble = $preamble; + $this->body = $body; + + return $this; } /** diff --git a/src/Util/EMailer/SystemMailBuilder.php b/src/Util/EMailer/SystemMailBuilder.php index 24c1593c98..7f8a22b9d5 100644 --- a/src/Util/EMailer/SystemMailBuilder.php +++ b/src/Util/EMailer/SystemMailBuilder.php @@ -38,9 +38,7 @@ class SystemMailBuilder extends MailBuilder } // Set the system wide site address/name as sender (default for system mails) - $this->senderName = $siteName; - $this->senderAddress = $siteEmailAddress; - $this->senderNoReply = $siteEmailAddress; + $this->withSender($siteName, $siteEmailAddress, $siteEmailAddress); } /** diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index 1717b994a4..0e45936014 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -96,13 +96,11 @@ class Emailer * * @see Notify * - * @param L10n $l10n The chosen language for the new email - * * @return NotifyMailBuilder */ - public function newNotifyMail(L10n $l10n) + public function newNotifyMail() { - return new NotifyMailBuilder($l10n, $this->baseUrl, $this->config, + return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->getSiteEmailAddress(), $this->getSiteEmailName()); }