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 7d15c2f352)
This commit is contained in:
nathangray 2021-06-08 10:22:48 -06:00
parent 26e186fb8c
commit 1bed2d2df6
3 changed files with 34 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}
/**

View File

@ -31,6 +31,17 @@
<option value="True">Yes</option>
</select>
</row>
<row>
<description value="Account" span="all" class="subHeader"/>
</row>
<row>
<description value="User to use for async notifications"/>
<select-account id="newsettings[async_account]"/>
</row>
<row>
<description value="Email address to use for async notifications"/>
<url-email id="newsettings[async_email]"/>
</row>
<row>
<description value="Signature" span="all" class="subHeader"/>
</row>