From 1bed2d2df609bbcc25c197c3dc8d5b8021bb1b99 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 8 Jun 2021 10:22:48 -0600 Subject: [PATCH] Notifications: Add configuration for account / address to use for sending notification emails If the app specifies a different sender (Calendar) that is still used instead. (cherry picked from commit 7d15c2f3521c64a412b03d6f5e643d0bbe112eb8) --- notifications/inc/class.notifications.inc.php | 8 ++++++++ .../inc/class.notifications_email.inc.php | 16 +++++++++++++++- notifications/templates/default/config.xet | 11 +++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index ac9ecec83c..d1f87507c4 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -215,6 +215,14 @@ class notifications { * it's an int with the account id or the e-mail address of a non-eGW user */ public function set_sender($_sender) { + // Check configured sender first - that overrides all + $config = Api\Config::read('notifications'); + if($config && ($config['async_account' || $config['async_email']])) + { + $send_user = $config['async_account']; + $email = $config['async_email'] ?: $GLOBALS['egw']->accounts->id2name($send_user,'account_email'); + } + if(is_object($_sender)) { $this->sender = $_sender; return true; diff --git a/notifications/inc/class.notifications_email.inc.php b/notifications/inc/class.notifications_email.inc.php index 615f748f20..f86e048b91 100644 --- a/notifications/inc/class.notifications_email.inc.php +++ b/notifications/inc/class.notifications_email.inc.php @@ -76,7 +76,21 @@ class notifications_email implements notifications_iface { { unset($this->mail); } - $this->mail = new Api\Mailer(); + + // Use configured mail ac + $ident = null; + if($this->config->async_account) + { + $mail_identities = Api\Mail\Account::identities([], true, 'params', $this->config->async_account); + foreach ($mail_identities as $mi) + { + if ($mi['ident_email'] == $this->config->async_email || !$this->config->async_email) + { + $ident = Api\Mail\Account::read($mi['acc_id']); + } + } + } + $this->mail = new Api\Mailer($ident); } /** diff --git a/notifications/templates/default/config.xet b/notifications/templates/default/config.xet index f9cc1afd42..b82bf8e616 100644 --- a/notifications/templates/default/config.xet +++ b/notifications/templates/default/config.xet @@ -31,6 +31,17 @@ + + + + + + + + + + +