--- old/core/email_api.php 2018-04-16 13:01:22.100461100 +0200 +++ new/core/email_api.php 2018-04-16 14:23:17.076137200 +0200 @@ -523,7 +523,9 @@ function email_signup( $p_user_id, $p_co # Send signup email regardless of mail notification pref # or else users won't be able to sign up if( !is_blank( $t_email ) ) { - email_store( $t_email, $t_subject, $t_message, null, true ); + $t_params = array('admin_name' => $p_admin_name, 'user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash); + email_store( $t_email, $t_subject, $t_message, 'email_notification_signup', $t_params, null, true ); + log_event( LOG_EMAIL, 'Signup Email = %s, Hash = %s, User = @U%d', $t_email, $p_confirm_hash, $p_user_id ); } @@ -562,7 +564,8 @@ function email_send_confirm_hash_url( $p # Send password reset regardless of mail notification preferences # or else users won't be able to receive their reset passwords if( !is_blank( $t_email ) ) { - email_store( $t_email, $t_subject, $t_message, null, true ); + $t_params = array('user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash); + email_store( $t_email, $t_subject, $t_message, 'email_notification_forgotten_password', $t_params, null, true ); log_event( LOG_EMAIL, 'Password reset for user @U%d sent to %s', $p_user_id, $t_email ); } else { log_event( LOG_EMAIL, 'Password reset for user @U%d not sent, email is empty', $p_user_id ); @@ -595,7 +598,8 @@ function email_notify_new_account( $p_us $t_message = lang_get( 'new_account_signup_msg' ) . "\n\n" . lang_get( 'new_account_username' ) . ' ' . $p_username . "\n" . lang_get( 'new_account_email' ) . ' ' . $p_email . "\n" . lang_get( 'new_account_IP' ) . ' ' . $_SERVER['REMOTE_ADDR'] . "\n" . config_get_global( 'path' ) . "\n\n" . lang_get( 'new_account_do_not_reply' ); if( !is_blank( $t_recipient_email ) ) { - email_store( $t_recipient_email, $t_subject, $t_message ); + + email_store( $t_email, $t_subject, $t_message, 'email_notification_new_account' ); log_event( LOG_EMAIL, 'New Account Notify for email = \'%s\'', $t_recipient_email ); } @@ -1134,7 +1138,8 @@ function email_bug_deleted( $p_bug_id ) * even when using cronjob * @return integer|null */ -function email_store( $p_recipient, $p_subject, $p_message, array $p_headers = null, $p_force = false ) { +function email_store( $p_recipient, $p_subject, $p_message, $p_message_id = null, $p_params = null, array $p_headers = null, $p_force = false ) { + global $g_email_shutdown_processing; $t_recipient = trim( $p_recipient ); @@ -1169,6 +1174,8 @@ function email_store( $p_recipient, $p_s } $t_email_data->metadata['hostname'] = $t_hostname; + $t_email_data = event_signal('EVENT_NOTIFY_EMAIL', $t_email_data, array( 'message_id' => $p_message_id, 'params' => $p_params,)); + $t_email_id = email_queue_add( $t_email_data ); # Set the email processing flag for the shutdown function @@ -1300,7 +1307,7 @@ function email_send( EmailData $p_email_ break; } - $t_mail->IsHTML( false ); # set email format to plain text + $t_mail->IsHTML( isset( $t_email_data->metadata['Content-Type'] ) && stripos( $t_email_data->metadata['Content-Type'], "text/html" ) !== false ); $t_mail->WordWrap = 80; # set word wrap to 80 characters $t_mail->CharSet = $t_email_data->metadata['charset']; $t_mail->Host = config_get( 'smtp_host' ); @@ -1482,7 +1489,8 @@ function email_bug_reminder( $p_recipien $t_header = "\n" . lang_get( 'on_date' ) . ' ' . $t_date . ', ' . $t_sender . ' ' . $t_sender_email . lang_get( 'sent_you_this_reminder_about' ) . ': ' . "\n\n"; $t_contents = $t_header . string_get_bug_view_url_with_fqdn( $p_bug_id ) . " \n\n" . $p_message; - $t_id = email_store( $t_email, $t_subject, $t_contents ); + $t_params = array( 'message' => $p_message, 'bug_id' => $p_bug_id, 'recipient' => $t_recipient, 'sender' => $t_sender, 'sender_email' => $t_sender_email ); + $t_id = email_store( $t_email, $t_subject, $t_contents,'email_bug_reminder', $t_params ); if( $t_id !== null ) { $t_result[] = $t_recipient; } @@ -1615,9 +1623,8 @@ function email_bug_info_to_one_user( arr } else { $t_mail_headers['In-Reply-To'] = $t_message_md5; } - # send mail - email_store( $t_user_email, $t_subject, $t_message, $t_mail_headers ); + email_store( $t_user_email, $t_subject, $t_message, $p_message_id, array_merge($p_visible_bug_data, array('header_optional_params' => $p_header_optional_params)), $t_mail_headers); return; } --- old/core/events_inc.php 2018-04-16 13:01:18.674086000 +0200 +++ new/core/events_inc.php 2018-04-16 14:20:31.752531500 +0200 @@ -138,6 +138,7 @@ event_declare_many( array( # Email notification events 'EVENT_NOTIFY_USER_INCLUDE' => EVENT_TYPE_DEFAULT, 'EVENT_NOTIFY_USER_EXCLUDE' => EVENT_TYPE_DEFAULT, + 'EVENT_NOTIFY_EMAIL' => EVENT_TYPE_CHAIN, # Wiki events 'EVENT_WIKI_INIT' => EVENT_TYPE_FIRST, --- old/manage_user_update.php 2018-04-16 13:01:09.928648900 +0200 +++ new/manage_user_update.php 2018-04-16 14:16:15.655752900 +0200 @@ -205,7 +205,7 @@ if( $f_send_email_notification ) { $t_updated_msg = lang_get( 'email_user_updated_msg' ); $t_message = $t_updated_msg . "\n\n" . config_get( 'path' ) . 'account_page.php' . "\n\n" . $t_changes; - if( null === email_store( $t_email, $t_subject, $t_message ) ) { + if( null === email_store( $f_email, $t_subject, $t_message, 'email_notification_user_update', array( 'changes' => $t_changes ) ) ) { log_event( LOG_EMAIL, 'Notification was NOT sent to ' . $f_username ); } else { log_event( LOG_EMAIL, 'Account update notification sent to ' . $f_username . ' (' . $t_email . ')' );