Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 10 years ago

#3270 closed defect (bug) (fixed)

Default 'From' address on mails sent from BuddyPress

Reported by: bojote Owned by:
Milestone: 1.6 Priority: normal
Severity: normal Version: 1.2.8
Component: Core Keywords: needs-patch dev-feedback
Cc:

Description

I believe there is a bug in the way Buddypress handles 'From' addresses in the bp_core_email_from_address_filter function located in bp-core-filters.php. It does not care if a From address was previously set!

Consider the following:

wp-includes/pluggable.php contains the code:
$phpmailer->From = apply_filters( 'wp_mail_from', $from_email );

The From address used in the PHPMailer will be set to whatever the $from_email was set to above. IF $from_email is empty, then WP will 'create' a From address based on 'sitename' to something like 'wordpress@' . domain.com. So far, this is all good and is WP default behavior, however, Buddypress introduces the following bug:

Line 27 on bp-core-filters.php shows that bp_core_email_from_address_filter always returns a noreply@… on ALL CASES! it does NOT take any arguments, so if you have properly set a $from_email buddypress will NOT care and it will ALWAYS return noreply@… as the From email address ignoring ANY addresses set. Question is, why not use the $from_email that is being passed as an argument?

Change History (6)

#1 @DJPaul
11 years ago

  • Keywords needs-patch added; bp_core_email_from_address_filter wp_mail_from removed
  • Milestone changed from Awaiting Review to 1.4

I have no idea. I don't even think BuddyPress needs its filter, fullstop. This piece of code has been around since the days when BuddyPress required WPMU (even though it has wordpressmu_wp_mail_from()), I am wondering if it fixed something at one point in time.

As WordPress sets a default email address just above the line you pasted, we can probably just remove BP's filter/function. Patches welcome :)

#2 @DJPaul
11 years ago

Unless $_SERVERSERVER_NAME? is sometimes blank?

#3 @DJPaul
10 years ago

  • Keywords 2nd-opinion added
  • Severity set to normal

I think we can remove this filter, but I'd like a second opinion.

#4 @DJPaul
10 years ago

This filter was in BP 1.0, and looking back at the early WPMU, and some of the comments in WordPress' code, I can see why this filter was probably useful. By default, WP sends emails from "WordPress@…". BP filters it to "noreply@…" which may be better, but I think that's more of discussion for WordPress core to have.

If a "from" header is passed to wp_mail(), probably by another plugin, BP's filter overrides it.

As I've never seen a user complain about their site's emails "from" address change after they've installed BuddyPress, I doubt anyone would bat an eyelid if BP's filter was removed.

#5 @DJPaul
10 years ago

  • Keywords dev-feedback added; 2nd-opinion removed

I suggest we just remove the add_filter() line for bp_core_email_from_address_filter, Function can be moved to the deprecated file. Any dev feedback?

#6 @djpaul
10 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5556]) Deprecate legacy "from address" email filter. Fixes #3270

Note: See TracTickets for help on using tickets.