Skip to:
Content

bbPress.org

Ticket #2162: 2162.patch

File 2162.patch, 4.1 KB (added by johnjamesjacoby, 11 years ago)

Switch to BCC with noreply@ kludge

  • includes/common/functions.php

     
    10171017function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) {
    10181018
    10191019        // Bail if subscriptions are turned off
    1020         if ( !bbp_is_subscriptions_active() )
     1020        if ( !bbp_is_subscriptions_active() ) {
    10211021                return false;
     1022        }
    10221023
    10231024        /** Validation ************************************************************/
    10241025
     
    10291030        /** Reply *****************************************************************/
    10301031
    10311032        // Bail if reply is not published
    1032         if ( !bbp_is_reply_published( $reply_id ) )
     1033        if ( !bbp_is_reply_published( $reply_id ) ) {
    10331034                return false;
     1035        }
    10341036
     1037        // Poster name
     1038        $reply_author_name = bbp_get_reply_author_display_name( $reply_id );
     1039
    10351040        /** Topic *****************************************************************/
    10361041
    10371042        // Bail if topic is not published
    1038         if ( !bbp_is_topic_published( $topic_id ) )
     1043        if ( !bbp_is_topic_published( $topic_id ) ) {
    10391044                return false;
     1045        }
    10401046
    1041         /** User ******************************************************************/
    1042 
    1043         // Get topic subscribers and bail if empty
    1044         $user_ids = bbp_get_topic_subscribers( $topic_id, true );
    1045         if ( empty( $user_ids ) )
    1046                 return false;
    1047 
    1048         // Poster name
    1049         $reply_author_name = bbp_get_reply_author_display_name( $reply_id );
    1050 
    10511047        /** Mail ******************************************************************/
    10521048
    10531049        do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
     
    10631059        $reply_url     = bbp_get_reply_url( $reply_id );
    10641060        $blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    10651061
    1066         // Loop through users
    1067         foreach ( (array) $user_ids as $user_id ) {
    1068 
    1069                 // Don't send notifications to the person who made the post
    1070                 if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author )
    1071                         continue;
    1072 
    10731062                // For plugins to filter messages per reply/topic/user
    10741063                $message = sprintf( __( '%1$s wrote:
    10751064
     
    10881077                        $reply_url
    10891078                );
    10901079
    1091                 $message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id );
    1092                 if ( empty( $message ) )
    1093                         continue;
     1080        $message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id );
     1081        if ( empty( $message ) ) {
     1082                return;
     1083        }
    10941084
    10951085                // For plugins to filter titles per reply/topic/user
    1096                 $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id );
    1097                 if ( empty( $subject ) )
     1086        $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id );
     1087        if ( empty( $subject ) ) {
     1088                return;
     1089        }
     1090
     1091        /** Users *****************************************************************/
     1092
     1093        // Do not reply address
     1094        $do_not_reply = 'noreply@' . get_bloginfo( 'url' );
     1095
     1096        // Array to hold BCC's
     1097        $headers = array();
     1098
     1099        // Setup the From header
     1100        $headers[] = 'From: . ' . get_bloginfo( 'name' ) . $do_not_reply;
     1101       
     1102        // Get topic subscribers and bail if empty
     1103        $user_ids = bbp_get_topic_subscribers( $topic_id, true );
     1104        if ( empty( $user_ids ) ) {
     1105                return false;
     1106        }
     1107
     1108        // Loop through users
     1109        foreach ( (array) $user_ids as $user_id ) {
     1110
     1111                // Don't send notifications to the person who made the post
     1112                if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author ) {
    10981113                        continue;
     1114                }
    10991115
    1100                 // Custom headers
    1101                 $headers = apply_filters( 'bbp_subscription_mail_headers', array() );
     1116                // Get email address of subscribed user
     1117                $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email;
     1118        }
    11021119
    1103                 // Get user data of this user
    1104                 $user = get_userdata( $user_id );
     1120        /** Send it ***************************************************************/
    11051121
     1122        // Custom headers
     1123        $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
     1124
    11061125                // Send notification email
    1107                 wp_mail( $user->user_email, $subject, $message, $headers );
    1108         }
     1126        wp_mail( $do_not_reply, $subject, $message, $headers );
    11091127
    11101128        do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
    11111129