$result = $db->sql_query($sql);
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$email_tpl = $user_id ? 'profile_send_email' : 'email_notify';
$messenger->template($email_tpl, $email_lang);
$messenger->replyto($user->data['user_email']);
$messenger->to($email, $name);
if ($user_id) {
$messenger->subject(html_entity_decode($subject));
$messenger->im($row['user_jabber'], $row['username']);
$notify_type = $row['user_notify_type'];
} else {
$notify_type = NOTIFY_EMAIL;
}
if ($cc) {
$messenger->cc($user->data['user_email'], $user->data['username']);
}
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_contact'], 'TO_USERNAME' => html_entity_decode($name), 'FROM_USERNAME' => html_entity_decode($user->data['username']), 'MESSAGE' => html_entity_decode($message)));
if ($topic_id) {
$messenger->assign_vars(array('TOPIC_NAME' => html_entity_decode($row['topic_title']), 'U_TOPIC' => generate_board_url() . "/viewtopic.{$phpEx}?f=" . $row['forum_id'] . "&t={$topic_id}"));
}
$messenger->send($notify_type);
$messenger->save_queue();
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
$message = $user_id ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$row['forum_id']}&t={$topic_id}") . '">', '</a>');
trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
}