mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-09 07:28:43 +01:00
allow notification to set sender different from current user / async-job owner
This commit is contained in:
parent
e1cf90169b
commit
df166d4f43
@ -68,8 +68,9 @@ class Mailer extends Horde_Mime_Mail
|
|||||||
* @param int|Mail\Account|boolean $account =null mail account to use, default use Mail\Account::get_default($smtp=true)
|
* @param int|Mail\Account|boolean $account =null mail account to use, default use Mail\Account::get_default($smtp=true)
|
||||||
* false: no NOT initialise account and set other EGroupware specific headers, used to parse mails (not sending them!)
|
* false: no NOT initialise account and set other EGroupware specific headers, used to parse mails (not sending them!)
|
||||||
* initbasic: return $this
|
* initbasic: return $this
|
||||||
|
* @param int|null $called_for account_id to use as sender, default $GLOBALS[egw_info][user][account_id]
|
||||||
*/
|
*/
|
||||||
function __construct($account=null)
|
function __construct($account=null, int $called_for=null)
|
||||||
{
|
{
|
||||||
// Horde use locale for translation of error messages
|
// Horde use locale for translation of error messages
|
||||||
Preferences::setlocale(LC_MESSAGES);
|
Preferences::setlocale(LC_MESSAGES);
|
||||||
@ -86,7 +87,7 @@ class Mailer extends Horde_Mime_Mail
|
|||||||
{
|
{
|
||||||
$this->_headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['api']);
|
$this->_headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['api']);
|
||||||
|
|
||||||
$this->setAccount($account);
|
$this->setAccount($account, $called_for);
|
||||||
|
|
||||||
$this->is_html = false;
|
$this->is_html = false;
|
||||||
|
|
||||||
@ -111,25 +112,23 @@ class Mailer extends Horde_Mime_Mail
|
|||||||
/**
|
/**
|
||||||
* Set mail account to use for sending
|
* Set mail account to use for sending
|
||||||
*
|
*
|
||||||
* @param int|Mail\Account $account =null mail account to use, default use Mail\Account::get_default($smtp=true)
|
* @param int|Mail\Account|null $account =null mail account to use, default use Mail\Account::get_default($smtp=true)
|
||||||
|
* @param int|null $called_for account_id to use as sender, default $GLOBALS[egw_info][user][account_id]
|
||||||
* @throws Exception\NotFound if account was not found (or not valid for current user)
|
* @throws Exception\NotFound if account was not found (or not valid for current user)
|
||||||
*/
|
*/
|
||||||
function setAccount($account=null)
|
function setAccount($account=null, int $called_for=null)
|
||||||
{
|
{
|
||||||
if ($account instanceof Mail\Account)
|
if ($account instanceof Mail\Account)
|
||||||
{
|
{
|
||||||
$this->account = $account;
|
$this->account = $account;
|
||||||
}
|
}
|
||||||
elseif ($account > 0)
|
|
||||||
{
|
|
||||||
$this->account = Mail\Account::read($account);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!($this->account = Mail\Account::get_default(true))) // true = need an SMTP (not just IMAP) account
|
if (!($account > 0) && !($account = Mail\Account::get_default(true, true))) // true = need an SMTP (not just IMAP) account
|
||||||
{
|
{
|
||||||
throw new Exception\NotFound('SMTP: '.lang('Account not found!'));
|
throw new Exception\NotFound('SMTP: '.lang('Account not found!'));
|
||||||
}
|
}
|
||||||
|
$this->account = Mail\Account::read($account, $called_for);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -77,13 +77,13 @@ class notifications_email implements notifications_iface {
|
|||||||
unset($this->mail);
|
unset($this->mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use configured mail ac
|
// Use configured mail account
|
||||||
$ident = null;
|
$ident = null;
|
||||||
if($this->config->async_identity)
|
if($this->config->async_identity)
|
||||||
{
|
{
|
||||||
$ident = Api\Mail\Account::read($this->config->async_identity, $_sender->account_id ?? null);
|
$ident = Api\Mail\Account::read($this->config->async_identity, $_sender->account_id ?? null);
|
||||||
}
|
}
|
||||||
$this->mail = new Api\Mailer($ident);
|
$this->mail = new Api\Mailer($ident, $_sender->account_id ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user