mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-24 23:09:13 +01:00
docu update felamimail and disabled alert for error-messages, hook for egw_mailer to log or authorize all mail
This commit is contained in:
parent
a28c004536
commit
c0550a5d59
@ -62,10 +62,12 @@ class egw_mailer extends PHPMailer
|
|||||||
$msg .= ($isSent ? 'Mail send' : 'Mail NOT send').
|
$msg .= ($isSent ? 'Mail send' : 'Mail NOT send').
|
||||||
' to '.$to.' with subject: "'.trim($subject).'"';
|
' to '.$to.' with subject: "'.trim($subject).'"';
|
||||||
|
|
||||||
|
$msg .= ' from instance '.$GLOBALS['egw_info']['user']['domain'].' and IP '.egw_session::getuser_ip();
|
||||||
|
$msg .= ' from user #'.$GLOBALS['egw_info']['user']['account_id'];
|
||||||
|
|
||||||
if ($GLOBALS['egw_info']['user']['account_id'] && class_exists('common',false))
|
if ($GLOBALS['egw_info']['user']['account_id'] && class_exists('common',false))
|
||||||
{
|
{
|
||||||
$msg .= ' from user #'.$GLOBALS['egw_info']['user']['account_id'].' ('.
|
$msg .= ' ('.common::grab_owner_name($GLOBALS['egw_info']['user']['account_id']).')';
|
||||||
common::grab_owner_name($GLOBALS['egw_info']['user']['account_id']).')';
|
|
||||||
}
|
}
|
||||||
if (!$isSent)
|
if (!$isSent)
|
||||||
{
|
{
|
||||||
@ -74,6 +76,7 @@ class egw_mailer extends PHPMailer
|
|||||||
$msg .= 'ERROR '.str_replace(array('Language string failed to load: smtp_error',"\n","\r"),'',
|
$msg .= 'ERROR '.str_replace(array('Language string failed to load: smtp_error',"\n","\r"),'',
|
||||||
strip_tags($this->ErrorInfo));
|
strip_tags($this->ErrorInfo));
|
||||||
}
|
}
|
||||||
|
$msg .= " cc=$cc, bcc=$bcc";
|
||||||
if ($GLOBALS['egw_info']['server']['log_mail'] !== true) $msg .= "\n\n";
|
if ($GLOBALS['egw_info']['server']['log_mail'] !== true) $msg .= "\n\n";
|
||||||
|
|
||||||
error_log($msg,$GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3,
|
error_log($msg,$GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3,
|
||||||
@ -82,4 +85,54 @@ class egw_mailer extends PHPMailer
|
|||||||
// calling the orginal callback of phpMailer
|
// calling the orginal callback of phpMailer
|
||||||
parent::doCallback($isSent,$to,$cc,$bcc,$subject,$body);
|
parent::doCallback($isSent,$to,$cc,$bcc,$subject,$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $addresses = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends mail via SMTP using PhpSMTP
|
||||||
|
*
|
||||||
|
* Overwriting this method from phpmailer, to allow apps to intercept it
|
||||||
|
* via "send_mail" hook, eg. to log or authorize sending of mail.
|
||||||
|
* Hooks can throw phpmailerException($message, phpMailer::STOP_CRITICAL),
|
||||||
|
* to stop sending the mail out like an SMTP error.
|
||||||
|
*
|
||||||
|
* @param string $header The message headers
|
||||||
|
* @param string $body The message body
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function SmtpSend($header, $body)
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->hooks->process(array(
|
||||||
|
'location' => 'send_mail',
|
||||||
|
'subject' => $this->Subject,
|
||||||
|
'from' => $this->Sender ? $this->Sender : $this->From,
|
||||||
|
'to' => $this->addresses['To'],
|
||||||
|
'cc' => $this->addresses['Cc'],
|
||||||
|
'bcc' => $this->addresses['Bcc'],
|
||||||
|
'body_sha1' => sha1($body),
|
||||||
|
'message_id' => preg_match('/^Message-ID: (.*)$/m', $header,$matches) ? $matches[1] : null,
|
||||||
|
), array(), true); // true = call all apps
|
||||||
|
|
||||||
|
$this->addresses = array(); // reset addresses for next mail
|
||||||
|
|
||||||
|
// calling the overwritten method
|
||||||
|
return parent::SmtpSend($header, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates recipient headers.
|
||||||
|
*
|
||||||
|
* Overwritten to get To, Cc and Bcc addresses, which are private in phpMailer
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function AddrAppend($type, $addr)
|
||||||
|
{
|
||||||
|
foreach($addr as $data)
|
||||||
|
{
|
||||||
|
$this->addresses[$type] .= ($this->addresses[$type] ? ', ' : '').$data[0];
|
||||||
|
}
|
||||||
|
return parent::AddrAppend($type, $addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user