Skip to:
Content

bbPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 7 months ago

#2618 closed defect (bug) (fixed)

Default "do not reply" email address needs a filter

Reported by: sudar's profile sudar Owned by: netweb's profile netweb
Milestone: 2.5.6 Priority: highest omg sweet tea
Severity: major Version: 2.5.4
Component: API - Subscriptions Keywords: has-patch
Cc: sudar@…, unsalkorkmaz@…

Description

With the recent bbPress update, the way notification is sent is changed. Earlier individual emails are sent to each people, but now only one email is sent with all the email address in bcc. I guess this is done to prevent email bottleneck. But this seems to have caused an issue in my setup.

I use wpmandrill to send emails through the mandrill service. With the new change, the "to" and "from" address is changed to a default “do not reply” email address that is calculated using the current domain name. The code is present in the bbpress/includes/common/functions.php https://bbpress.trac.wordpress.org/browser/trunk/src/includes/common/functions.php#L1065

$do_not_reply = '<noreply@' . ltrim( get_home_url(), '^(http|https)://' ) . '>';

So it becomes <nobody@…>

When this address is used as “to” address, the mandrill service thinks that it is an invalid email address because of the angle brackets.

I went through the code, but there is no filter to change the $do_not_reply variable. It would be nice to add a filter so that if people (like me) need to change it can change it using a filter instead of modifying the core files.

I can prepare a patch if needed.

Attachments (6)

2618.diff (2.4 KB) - added by netweb 10 years ago.
2618.2.diff (2.0 KB) - added by netweb 10 years ago.
2618.3.diff (3.3 KB) - added by sudar 10 years ago.
Added filter for both from and to address
2618.4.diff (574 bytes) - added by netweb 10 years ago.
2618.5.diff (562 bytes) - added by netweb 10 years ago.
2618.5-25branch.diff (1.2 KB) - added by netweb 10 years ago.

Download all attachments as: .zip

Change History (35)

#1 @sudar
10 years ago

  • Cc sudar@… added

@netweb
10 years ago

#2 @netweb
10 years ago

  • Component changed from Actions/Filters to Subscriptions
  • Keywords has-patch added; dev-feedback removed
  • Milestone changed from Awaiting Review to 2.6
  • Owner set to netweb

Thanks, I'd say this slipped past us as some mail servers were automatically stripping the brackets.

We are using $do_not_reply for both the To: and From: email addresses wp_mail expects To: addresses to be formatted user@example.com, not <user@example.com>, the email address only gets wrapped in brackets when using a name and email as bbPress does for the From: headers e.g. User <user@example.com>.

Patch moves the brackets from $do_not_reply to the $headers and also adds a bbp_subscription_do_not_reply filter for forum and topic subscriptions. The same filter is used for forum and topic subscriptions similar to the custom headers filter bbp_subscription_mail_headers

Related: r5259 This changeset fixed the From: without taking into account $do_not_reply is also used for To:

#3 follow-up: @sudar
10 years ago

There is still one small issue in the patch.

The bbp_subscription_do_not_reply filter is applied to $do_not_reply after it is included in from address.

Can we move the apply_filter line before it $do_not_reply is added to the from address? In that way a plugin developer can change both the from and to email address.

@netweb
10 years ago

#4 in reply to: ↑ 3 @netweb
10 years ago

Replying to sudar:

There is still one small issue in the patch.

The bbp_subscription_do_not_reply filter is applied to $do_not_reply after it is included in from address.

Can we move the apply_filter line before it $do_not_reply is added to the from address? In that way a plugin developer can change both the from and to email address.

Thanks, missed that ;) Fixed in 2618.2.diff

@sudar
10 years ago

Added filter for both from and to address

#5 @sudar
10 years ago

While we are at it, I thought it would make sense to use separate filters for the from and to addresses and modified the patch 2618.3.diff

#6 @netweb
10 years ago

Thanks Sudar, I like it, and thanks for the updated patch :)

#7 @leanderbraunschweig
10 years ago

As stated in https://bbpress.trac.wordpress.org/ticket/2162#comment:27, we are also having issues with the recent changes in our mail setup, specifically due to the way the noreply-address is generated which results in delivery erros due to a missing MX-record.

Right now, notification-mails are sent to noreply(AT)www.our-site.info which causes errors (should be noreply(AT)our-site.info).

Both home_url and site_url are set identically (www.our-site.info) and we are redirecting traffic from non-www to www on a server-level. Other than that we have had no problems whatsoever with other plugins / mail configurations appending 'www' to email-addresses so this seems to be pretty bbPress-specific.

Seeing that the filter will be moved I am hoping that our setup (using GD bbPress Toolbox for our notifications) can tweak the from-address...

Thanks for your efforts / support!

#8 @netweb
10 years ago

See also http://bbpress.org/forums/topic/reply-email-notifications-are-not-being-sent/

Quite sure we need to strip any www characters that are included with get_home_url, it would be rare for any setups to be including www as a mail alias as part of the domain name in their DNS configurations.

#9 @johnjamesjacoby
10 years ago

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

In 5409:

Introduce bbp_get_do_not_reply_address() function, and use in subscription notification functions. Also add filters to make changing these values easier for advanced setups. Fixes #2618.

@netweb
10 years ago

#10 @netweb
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Via bbpress.org

Using the current method:

$email = 'noreply@' . str_replace( 'www.', '', ltrim( get_home_url(), '^(http|https)://' ) );

Results in ltrim's 'character mask' (not a regular expression) stripping all the s's

eg http://ssssssseanwes.com/ or https://ssssssseanwes.com/ becomes eanwes.com

Patch 2618.4.diff strips http://, https:// and www. if they exist in get_home_url()

$email = 'noreply@' . str_replace( array( 'http://', 'https://', 'www.' ), '', get_home_url() );

#11 @netweb
10 years ago

Notes: The WordPress plugin wpMandrill does not support a BCC: list of email users, associated discussion here. If you are a wpMandrill user for now you will need to disable sending bbPress notification emails with the Mandrill API until BCC support is added to wpMandrill, this plugin will do that.

#12 @sudar
10 years ago

If you are a wpMandrill user for now you will need to disable sending bbPress notification emails with the Mandrill API until BCC support is added to wpMandrill, this plugin will do that.

Or you can this plugin which allows you to send bcc emails through wpMandrill.

#13 @nicmare
10 years ago

i have the exact same problem like leanderbraunschweig.
both home-url and site-url contain www.site.com .
and since the last update of bbpress, the $do_not_reply variable causes an annoying error which results in a mail delivery error:

<noreply@www.site.com>: mail for www.site.com loops back to myself

how do i remove the www ?
at the moment i changed line 1065 and 1205 to

$do_not_reply  = '<noreply@' . ltrim( get_home_url(), '^(http|https)://www.' ) . '>';

which works as expected

Last edited 10 years ago by nicmare (previous) (diff)

#14 @sudar
10 years ago

Right now the only option is to change the code like how you did. The issue that you are facing is fixed and hopefully the fix will be available as part of the next release of bbPress. @netweb might be able to give the approximate date of release of next version of bbPress.

#15 @ColinF
10 years ago

Hello -
Seems I am also caught in the same "Mandrill won't send to more than one Bcc address" . . .
Sudar - THANK you -- your plugin DOES work for me.
However -- I have one other issue with it . . . (forgive me, I'm NOT a programmer / coder . . more just a 'hacker' - so I hope I'm not asking a really stupid question here) . . . .

When I use Sudar's plugin - it seems to fix the Mandrill issue - and sends to all subscribers (yay!)

-- The problem is: a second email is also being sent to all subscribers -- and that one is NOT going through Mandrill

(maybe this is due to another plugin interference - I don't know yet)

I need to use Mandrill for ALL emails that go out from my site - or my web host will shut me down for abuse.

Is there a way that I can use Sudar's plugin -- and also 'block' all other wp-mail from going out?

Thanks in advance - for any help you can send my way - I will keep working (in "hacking mode" in the meantime.

#16 @netweb
10 years ago

  • Priority changed from normal to highest
  • Severity changed from normal to major

#2701 was marked as a duplicate.

We can use str_replace 2618.4.diff patch:

$email = 'noreply@' . str_replace( array( 'http://', 'https://', 'www.' ), '', get_home_url() ); 

Or alternitively preg_replace per DJPaul's patch in #2701 (Slightly modified regex than the bbpress-2701.01.patch​)

$email = 'noreply@' . preg_replace( '^(https?:\/\/)(www\.)?', '', get_home_url() );

#17 @unsalkorkmaz
10 years ago

Finally i found the problem but i seriously didnt expect that bbpress core is the problem, lol.

My site is: http://theme.firmasite.com

I was getting lots of Delivery Status Notification to

noreply@eme.firmasite.com

Did you realize the problem? Site adress is theme.firmasite.com but system trying to send it to eme.firmasite.com

#18 @unsalkorkmaz
10 years ago

  • Cc unsalkorkmaz@… added

This ticket was mentioned in Slack in #bbpress by netweb. View the logs.


10 years ago

This ticket was mentioned in Slack in #bbpress by sudar. View the logs.


10 years ago

#21 @netweb
10 years ago

  • Milestone changed from 2.6 to 2.5.6
  • Version changed from trunk to 2.5.4

@netweb
10 years ago

#22 @netweb
10 years ago

In 2618.5.diff I've used @DJPaul's patch from #2701 as these will correctly ignore casing if capital letters happened to be used for some reason in get_home_url()

#23 @netweb
10 years ago

In 2618.5-25branch.diff is for the 2.5 branch as r5409 only exists in /trunk as part of the 2.6 milestone.

#24 @netweb
10 years ago

In 5639:

Use preg_replace over incorrect ltrim usage in bbp_get_do_not_reply_address() causing undeliverable or invalid subscription emails in certain situations because the "from" address was incorrect.

Props DJPaul. See #2618 (2.5 Branch)

#25 @netweb
10 years ago

In 5640:

Use preg_replace over incorrect ltrim usage in bbp_get_do_not_reply_address() causing undeliverable or invalid subscription emails in certain situations because the "from" address was incorrect.

Props DJPaul. See #2618 (trunk)

#26 @netweb
10 years ago

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

To note:

  • The new filters in r5409 are in trunk and the 2.6 milestone.
  • The only change in the 2.5 branch is r5639.

#27 @johnjamesjacoby
10 years ago

In 5642:

Update bbp_get_do_not_reply_address() to use $_SERVER['SERVER_NAME'] over get_home_url() to improve compatibility with mapped domains and more complex installations. See #2618 (trunk)

This ticket was mentioned in Slack in #bbpress by netweb. View the logs.


10 years ago

#29 @johnjamesjacoby
10 years ago

In 5643:

Backport do_not_reply email address code from trunk to 2.5 branch (for what will be 2.5.6.) See #2618, r5642.

Note: See TracTickets for help on using tickets.