mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 05:48:51 +00:00
[ticket/15836] Event to send message via external transport
PHPBB3-15836
This commit is contained in:
parent
ca23d199c1
commit
c67dd0c591
1 changed files with 65 additions and 16 deletions
|
@ -521,7 +521,7 @@ class messenger
|
||||||
*/
|
*/
|
||||||
function msg_email()
|
function msg_email()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config, $phpbb_dispatcher;
|
||||||
|
|
||||||
if (empty($config['email_enable']))
|
if (empty($config['email_enable']))
|
||||||
{
|
{
|
||||||
|
@ -549,6 +549,33 @@ class messenger
|
||||||
$contact_name = htmlspecialchars_decode($config['board_contact_name']);
|
$contact_name = htmlspecialchars_decode($config['board_contact_name']);
|
||||||
$board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>';
|
$board_contact = (($contact_name !== '') ? '"' . mail_encode($contact_name) . '" ' : '') . '<' . $config['board_contact'] . '>';
|
||||||
|
|
||||||
|
$break = false;
|
||||||
|
$addresses = $this->addresses;
|
||||||
|
$subject = $this->subject;
|
||||||
|
$msg = $this->msg;
|
||||||
|
/**
|
||||||
|
* Event to send message via external transport
|
||||||
|
*
|
||||||
|
* @event core.notification_message_email
|
||||||
|
* @var bool break Flag indicating if the function return after hook
|
||||||
|
* @var array addresses The message recipients
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string msg The message text
|
||||||
|
* @since 3.2.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'break',
|
||||||
|
'addresses',
|
||||||
|
'subject',
|
||||||
|
'msg',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars)));
|
||||||
|
|
||||||
|
if ($break)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->replyto))
|
if (empty($this->replyto))
|
||||||
{
|
{
|
||||||
$this->replyto = $board_contact;
|
$this->replyto = $board_contact;
|
||||||
|
@ -787,7 +814,7 @@ class queue
|
||||||
*/
|
*/
|
||||||
function process()
|
function process()
|
||||||
{
|
{
|
||||||
global $config, $phpEx, $phpbb_root_path, $user;
|
global $config, $phpEx, $phpbb_root_path, $user, $phpbb_dispatcher;
|
||||||
|
|
||||||
$lock = new \phpbb\lock\flock($this->cache_file);
|
$lock = new \phpbb\lock\flock($this->cache_file);
|
||||||
$lock->acquire();
|
$lock->acquire();
|
||||||
|
@ -884,23 +911,45 @@ class queue
|
||||||
switch ($object)
|
switch ($object)
|
||||||
{
|
{
|
||||||
case 'email':
|
case 'email':
|
||||||
$err_msg = '';
|
$break = false;
|
||||||
$to = (!$to) ? 'undisclosed-recipients:;' : $to;
|
/**
|
||||||
|
* Event to send message via external transport
|
||||||
|
*
|
||||||
|
* @event core.notification_message_email
|
||||||
|
* @var bool break Flag indicating if the function return after hook
|
||||||
|
* @var array addresses The message recipients
|
||||||
|
* @var string subject The message subject
|
||||||
|
* @var string msg The message text
|
||||||
|
* @since 3.2.4-RC1
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'break',
|
||||||
|
'addresses',
|
||||||
|
'subject',
|
||||||
|
'msg',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.notification_message_email', compact($vars)));
|
||||||
|
|
||||||
if ($config['smtp_delivery'])
|
if (!$break)
|
||||||
{
|
{
|
||||||
$result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
|
$err_msg = '';
|
||||||
}
|
$to = (!$to) ? 'undisclosed-recipients:;' : $to;
|
||||||
else
|
|
||||||
{
|
|
||||||
$result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$result)
|
if ($config['smtp_delivery'])
|
||||||
{
|
{
|
||||||
$messenger = new messenger();
|
$result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
|
||||||
$messenger->error('EMAIL', $err_msg);
|
}
|
||||||
continue 2;
|
else
|
||||||
|
{
|
||||||
|
$result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$messenger = new messenger();
|
||||||
|
$messenger->error('EMAIL', $err_msg);
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue