--- old/core/email_api.php 2018-07-16 23:58:00.598800300 +0200 +++ new/core/email_api.php 2018-07-16 23:56:47.670800300 +0200 @@ -530,7 +530,8 @@ # 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 ); } @@ -569,7 +570,8 @@ # 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 ); @@ -602,7 +604,7 @@ $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 ); } @@ -1141,7 +1143,7 @@ * 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 ); @@ -1176,6 +1178,8 @@ } $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 @@ -1322,7 +1326,7 @@ $t_mail->DKIM_identity = config_get( 'email_dkim_identity' ); } - $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' ); @@ -1504,7 +1508,8 @@ $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; } @@ -1639,7 +1644,7 @@ } # 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; } diff -ruN old/core/events_inc.php new/core/events_inc.php --- old/core/events_inc.php 2018-07-16 23:57:54.820800300 +0200 +++ new/core/events_inc.php 2018-07-16 23:56:54.965800300 +0200 @@ -139,7 +139,8 @@ # 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, 'EVENT_WIKI_LINK_BUG' => EVENT_TYPE_FIRST, diff -ruN old/manage_user_update.php new/manage_user_update.php --- old/manage_user_update.php 2018-07-16 23:53:57.906800300 +0200 +++ new/manage_user_update.php 2018-07-16 23:55:26.088800300 +0200 @@ -205,7 +205,7 @@ $t_updated_msg = lang_get( 'email_user_updated_msg' ); $t_message = $t_updated_msg . "\n\n" . config_get_global( '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 . ')' );