function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="") { global $mybb, $plugins; // Get our mail handler. $mail = &get_my_mailhandler(); // If MyBB's built-in SMTP mail handler is used, set the keep alive bit accordingly. if($keep_alive == true && isset($mail->keep_alive) && isset($mybb->settings['mail_handler']) && $mybb->settings['mail_handler'] == 'smtp') { require_once MYBB_ROOT . "inc/class_mailhandler.php"; require_once MYBB_ROOT . "inc/mailhandlers/smtp.php"; if($mail instanceof MailHandler && $mail instanceof SmtpMail) { $mail->keep_alive = true; } } // Following variables will help sequential plugins to determine how to process plugin hooks. // Mark this variable true if the hooked plugin has sent the mail, otherwise don't modify it. $is_mail_sent = false; // Mark this variable false if the hooked plugin doesn't suggest sequential plugins to continue processing. $continue_process = true; $my_mail_parameters = array( 'to' => &$to, 'subject' => &$subject, 'message' => &$message, 'from' => &$from, 'charset' => &$charset, 'headers' => &$headers, 'keep_alive' => &$keep_alive, 'format' => &$format, 'message_text' => &$message_text, 'return_email' => &$return_email, 'is_mail_sent' => &$is_mail_sent, 'continue_process' => &$continue_process, ); if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_pre_build_message', $my_mail_parameters); } // Build the mail message. $mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email); if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_pre_send', $my_mail_parameters); } // Check if the hooked plugins still suggest to send the mail. if($continue_process) { $is_mail_sent = $mail->send(); } if(isset($plugins) && is_object($plugins)) { $plugins->run_hooks('my_mail_post_send', $my_mail_parameters); } return $is_mail_sent; }