Index: /branches/2.5/includes/common/functions.php
===================================================================
--- /branches/2.5/includes/common/functions.php	(revision 5257)
+++ /branches/2.5/includes/common/functions.php	(revision 5258)
@@ -988,4 +988,10 @@
  * if there are, send notifications
  *
+ * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email
+ * with everyone BCC'd. This may have negative repercussions for email services
+ * that limit the number of addresses in a BCC field (often to around 500.) In
+ * those cases, we recommend unhooking this function and creating your own
+ * custom emailer script.
+ * 
  * @since bbPress (r2668)
  *
@@ -1018,6 +1024,7 @@
 
 	// Bail if subscriptions are turned off
-	if ( !bbp_is_subscriptions_active() )
+	if ( !bbp_is_subscriptions_active() ) {
 		return false;
+	}
 
 	/** Validation ************************************************************/
@@ -1027,22 +1034,17 @@
 	$forum_id = bbp_get_forum_id( $forum_id );
 
+	/** Topic *****************************************************************/
+
+	// Bail if topic is not published
+	if ( !bbp_is_topic_published( $topic_id ) ) {
+		return false;
+	}
+
 	/** Reply *****************************************************************/
 
 	// Bail if reply is not published
-	if ( !bbp_is_reply_published( $reply_id ) )
+	if ( !bbp_is_reply_published( $reply_id ) ) {
 		return false;
-
-	/** Topic *****************************************************************/
-
-	// Bail if topic is not published
-	if ( !bbp_is_topic_published( $topic_id ) )
-		return false;
-
-	/** User ******************************************************************/
-
-	// Get topic subscribers and bail if empty
-	$user_ids = bbp_get_topic_subscribers( $topic_id, true );
-	if ( empty( $user_ids ) )
-		return false;
+	}
 
 	// Poster name
@@ -1050,6 +1052,4 @@
 
 	/** Mail ******************************************************************/
-
-	do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
 
 	// Remove filters from reply content and topic title to prevent content
@@ -1058,9 +1058,53 @@
 	remove_all_filters( 'bbp_get_topic_title'   );
 
-	// Strip tags from text
+	// Strip tags from text and setup mail data
 	$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
 	$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
 	$reply_url     = bbp_get_reply_url( $reply_id );
 	$blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
+	$do_not_reply = 'noreply@' . ltrim( get_home_url( null, '', 'relative' ), '/' );
+
+	// For plugins to filter messages per reply/topic/user
+	$message = sprintf( __( '%1$s wrote:
+
+%2$s
+
+Post Link: %3$s
+
+-----------
+
+You are receiving this email because you subscribed to a forum topic.
+
+Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
+
+		$reply_author_name,
+		$reply_content,
+		$reply_url
+	);
+
+	$message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id );
+	if ( empty( $message ) ) {
+		return;
+	}
+
+	// For plugins to filter titles per reply/topic/user
+	$subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id );
+	if ( empty( $subject ) ) {
+		return;
+	}
+
+	/** Users *****************************************************************/
+
+	// Array to hold BCC's
+	$headers = array();
+
+	// Setup the From header
+	$headers[] = 'From: . ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
+	
+	// Get topic subscribers and bail if empty
+	$user_ids = bbp_get_topic_subscribers( $topic_id, true );
+	if ( empty( $user_ids ) ) {
+		return false;
+	}
 
 	// Loop through users
@@ -1068,43 +1112,21 @@
 
 		// Don't send notifications to the person who made the post
-		if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author )
+		if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author ) {
 			continue;
-
-		// For plugins to filter messages per reply/topic/user
-		$message = sprintf( __( '%1$s wrote:
-
-%2$s
-
-Post Link: %3$s
-
------------
-
-You are receiving this email because you subscribed to a forum topic.
-
-Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
-
-			$reply_author_name,
-			$reply_content,
-			$reply_url
-		);
-
-		$message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id );
-		if ( empty( $message ) )
-			continue;
-
-		// For plugins to filter titles per reply/topic/user
-		$subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id );
-		if ( empty( $subject ) )
-			continue;
-
-		// Custom headers
-		$headers = apply_filters( 'bbp_subscription_mail_headers', array() );
-
-		// Get user data of this user
-		$user = get_userdata( $user_id );
-
-		// Send notification email
-		wp_mail( $user->user_email, $subject, $message, $headers );
-	}
+		}
+
+		// Get email address of subscribed user
+		$headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email;
+	}
+
+	/** Send it ***************************************************************/
+
+	// Custom headers
+	$headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
+
+	do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
+
+	// Send notification email
+	wp_mail( $do_not_reply, $subject, $message, $headers );
 
 	do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
@@ -1116,7 +1138,13 @@
  * Sends notification emails for new topics to subscribed forums
  *
- * Gets new post's ID and check if there are subscribed users to that topic, and
+ * Gets new post's ID and check if there are subscribed users to that forum, and
  * if there are, send notifications
  *
+ * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email
+ * with everyone BCC'd. This may have negative repercussions for email services
+ * that limit the number of addresses in a BCC field (often to around 500.) In
+ * those cases, we recommend unhooking this function and creating your own
+ * custom emailer script.
+ * 
  * @since bbPress (r5156)
  *
@@ -1144,6 +1172,7 @@
 
 	// Bail if subscriptions are turned off
-	if ( !bbp_is_subscriptions_active() )
+	if ( !bbp_is_subscriptions_active() ) {
 		return false;
+	}
 
 	/** Validation ************************************************************/
@@ -1155,13 +1184,7 @@
 
 	// Bail if topic is not published
-	if ( ! bbp_is_topic_published( $topic_id ) )
+	if ( ! bbp_is_topic_published( $topic_id ) ) {
 		return false;
-
-	/** User ******************************************************************/
-
-	// Get forum subscribers and bail if empty
-	$user_ids = bbp_get_forum_subscribers( $forum_id, true );
-	if ( empty( $user_ids ) )
-		return false;
+	}
 
 	// Poster name
@@ -1169,6 +1192,4 @@
 
 	/** Mail ******************************************************************/
-
-	do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
 
 	// Remove filters from reply content and topic title to prevent content
@@ -1177,9 +1198,53 @@
 	remove_all_filters( 'bbp_get_topic_title'   );
 
-	// Strip tags from text
+	// Strip tags from text and setup mail data
 	$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
 	$topic_content = strip_tags( bbp_get_topic_content( $topic_id ) );
 	$topic_url     = get_permalink( $topic_id );
 	$blog_name     = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
+	$do_not_reply  = 'noreply@' . ltrim( get_home_url( null, '', 'relative' ), '/' );
+
+	// For plugins to filter messages per reply/topic/user
+	$message = sprintf( __( '%1$s wrote:
+
+%2$s
+
+Topic Link: %3$s
+
+-----------
+
+You are receiving this email because you subscribed to a forum.
+
+Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
+
+		$topic_author_name,
+		$topic_content,
+		$topic_url
+	);
+
+	$message = apply_filters( 'bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id );
+	if ( empty( $message ) ) {
+		return;
+	}
+
+	// For plugins to filter titles per reply/topic/user
+	$subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id );
+	if ( empty( $subject ) ) {
+		return;
+	}
+
+	/** User ******************************************************************/
+
+	// Array to hold BCC's
+	$headers = array();
+
+	// Setup the From header
+	$headers[] = 'From: . ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
+	
+	// Get topic subscribers and bail if empty
+	$user_ids = bbp_get_forum_subscribers( $forum_id, true );
+	if ( empty( $user_ids ) ) {
+		return false;
+	}
 
 	// Loop through users
@@ -1187,42 +1252,21 @@
 
 		// Don't send notifications to the person who made the post
-		if ( !empty( $topic_author ) && (int) $user_id === (int) $topic_author )
+		if ( !empty( $topic_author ) && (int) $user_id === (int) $topic_author ) {
 			continue;
-
-		// For plugins to filter messages per reply/topic/user
-		$message = sprintf( __( '%1$s wrote:
-
-%2$s
-
-Topic Link: %3$s
-
------------
-
-You are receiving this email because you subscribed to a forum.
-
-Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
-
-			$topic_author_name,
-			$topic_content,
-			$topic_url
-		);
-		$message = apply_filters( 'bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id );
-		if ( empty( $message ) )
-			continue;
-
-		// For plugins to filter titles per reply/topic/user
-		$subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id );
-		if ( empty( $subject ) )
-			continue;
-
-		// Custom headers
-		$headers = apply_filters( 'bbp_forum_subscription_mail_headers', array() );
-
-		// Get user data of this user
-		$user = get_userdata( $user_id );
-
-		// Send notification email
-		wp_mail( $user->user_email, $subject, $message, $headers );
-	}
+		}
+
+		// Get email address of subscribed user
+		$headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email;
+	}
+
+	/** Send it ***************************************************************/
+
+	// Custom headers
+	$headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
+
+	do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
+
+	// Send notification email
+	wp_mail( $do_not_reply, $subject, $message, $headers );
 
 	do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
