diff options
Diffstat (limited to 'phpBB/includes/functions_messenger.php')
-rw-r--r-- | phpBB/includes/functions_messenger.php | 99 |
1 files changed, 79 insertions, 20 deletions
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index a85a3b67c5..8723dda7ff 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -37,7 +37,7 @@ class messenger /** * Constructor */ - function messenger($use_queue = true) + function __construct($use_queue = true) { global $config; @@ -327,6 +327,7 @@ class messenger $subject = $this->subject; $message = $this->msg; + $template = $this->template; /** * Event to modify notification message text before parsing * @@ -336,13 +337,16 @@ class messenger * and the message without sending it * @var string subject The message subject * @var string message The message text + * @var \phpbb\template\template template Template object * @since 3.1.11-RC1 + * @changed 3.2.4-RC1 Added template */ $vars = array( 'method', 'break', 'subject', 'message', + 'template', ); extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars))); $this->subject = $subject; @@ -369,6 +373,12 @@ class messenger $this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']); } + if (preg_match('#^(List-Unsubscribe:(.*?))$#m', $this->msg, $match)) + { + $this->extra_headers[] = $match[1]; + $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); + } + if ($drop_header) { $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); @@ -517,7 +527,7 @@ class messenger */ function msg_email() { - global $config; + global $config, $phpbb_dispatcher; if (empty($config['email_enable'])) { @@ -545,6 +555,33 @@ class messenger $contact_name = htmlspecialchars_decode($config['board_contact_name']); $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)) { $this->replyto = $board_contact; @@ -750,7 +787,7 @@ class queue /** * constructor */ - function queue() + function __construct() { global $phpEx, $phpbb_root_path, $phpbb_filesystem, $phpbb_container; @@ -783,7 +820,7 @@ class queue */ 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->acquire(); @@ -880,23 +917,45 @@ class queue switch ($object) { case 'email': - $err_msg = ''; - $to = (!$to) ? 'undisclosed-recipients:;' : $to; - - if ($config['smtp_delivery']) + $break = false; + /** + * Event to send message via external transport + * + * @event core.notification_message_process + * @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_process', compact($vars))); + + if (!$break) { - $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); - } - else - { - $result = phpbb_mail($to, $subject, $msg, $headers, PHP_EOL, $err_msg); - } + $err_msg = ''; + $to = (!$to) ? 'undisclosed-recipients:;' : $to; - if (!$result) - { - $messenger = new messenger(); - $messenger->error('EMAIL', $err_msg); - continue 2; + if ($config['smtp_delivery']) + { + $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers); + } + 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; @@ -1264,7 +1323,7 @@ class smtp_class var $backtrace = false; var $backtrace_log = array(); - function smtp_class() + function __construct() { // Always create a backtrace for admins to identify SMTP problems $this->backtrace = true; |