Skip to:
Content

bbPress.org

Opened 8 years ago

Closed 3 days ago

Last modified 44 hours ago

#3229 closed enhancement (fixed)

Subscription email unsubscribe links and headers

Reported by: johnjamesjacoby Owned by: johnjamesjacoby
Priority: high Milestone: 2.7
Component: API - Subscriptions Version: 2.0
Severity: normal Keywords: 2nd-opinion needs-patch
Cc: espellcaste

Description

In recent years, a number of new email headers have emerged to help protect recipients from spam and abuse. We should add support for them in the emails that are sent to forum & topic subscribers.

  • Require-Recipient-Valid-Since: %user last active time%
  • List-Unsubscribe: <%an unsubscribe url%>

Supporting these two headers will require a(nother) not-insignificant rethink of how user data is queried for and looped through, as bbPress now takes a very minimal approach to keep it speedy.

The first header value should probably come from user_registered, since that's the only place available to us where we can be confident that a user last verified their email address – nothing gets stored in usermeta when a user email address is changed.

The second header value is a bit of a problem because the links to toggle subscriptions have nonces on them, meaning their useful life is currently too low to be very effective in an email older than 24 hours.

To make matters worse, bbPress switched to using a new function in 2.6 to query for user email addresses in batches of 100, to address frequent complaints about user queries taking a long time on installs with large numbers of users. See: bbp_get_email_addresses_from_user_ids() and r6725, #3068.

Change History (13)

#1 @johnjamesjacoby
8 years ago

Things to think about:

Inside of bbp_get_email_addresses_from_user_ids(), we opted to use get_users() and use all_with_meta to prime the user objects for future/immediate use, and then just pluck user_email out of the results.

This means we can reference the user object and use user_registered without hitting the database, though we would be duplicating some effort with somewhat goofy function calls.

We also switched to sending 1 email and using Bcc: headers to minimize SMTP wait time inside of a foreach() loop, which is in direct conflict with sending unique headers per-user as would be required by this enhancement.

This is not very great, as I think we'd need to revert back to sending many individual emails again, something that has already proven to be problematic for users in the forums.

Last edited 8 years ago by johnjamesjacoby (previous) (diff)

#2 @dd32
8 years ago

The second header value is a bit of a problem because the links to toggle subscriptions have nonces on them, meaning their useful life is currently too low to be very effective in an email older than 24 hours.

Ideally they'd also work without logging in, so a signed url rather than a nonce would be used. I guess the url should double check their intention, but I'd check the RFC for those headers to find out the expected contents.

#3 @espellcaste
8 years ago

  • Cc espellcaste added

#4 @dd32
8 years ago

Related: #2707 (Include an unsubscribe link in emails)

#5 @johnjamesjacoby
8 years ago

  • Milestone 2.6 → 2.7

I'm going to move this to 2.7, so 2.6 can be shipped sooner without it.

This continues to be a high priority IMO, but I don't think I'll get to it in time for 2.6.

This ticket was mentioned in ​Slack in #forums by thelmachido. ​View the logs.


4 years ago

#7 @johnjamesjacoby
4 days ago

  • Summary Email header improvements → Subscription email unsubscribe links and headers

With term subscriptions now in trunk from #2989, I think this should cover forum, topic, and term subscription emails.

The WordPress.org support forums plugin has a working implementation we can port and generalize. It generates signed, expiring unsubscribe URLs, shows a confirmation form for normal GET requests, supports List-Unsubscribe=One-Click POST requests, adds the URL to the message body, and adds List-Unsubscribe and List-Unsubscribe-Post headers.

bbPress currently sends one message with recipients in Bcc, so a unique link also requires per-recipient delivery and enough context to identify the subscription being removed. This should preserve the existing notification hooks and filters, avoid duplicate mail when a user is subscribed through more than one source, and support forum, topic, and taxonomy subscriptions.

#2707 is the original request for the link in the message body. #2797 covers the related notification delivery work. This ticket can cover #2707 while leaving the remaining queue and delivery improvements in #2797.

#8 @johnjamesjacoby
3 days ago

  • Resolution → fixed
  • Status assigned → closed

In 8349:

Subscriptions: Add one-click unsubscribe.

Send one subscription notification per recipient so each message can include a signed, expiring unsubscribe URL and RFC 8058 headers. Support forum, topic, and taxonomy subscriptions, preserve the deprecated recipient filter for compatibility, and add a configurable confirmation route through theme compatibility.

Confirm normal link clicks before changing state, accept one-click POST requests, and keep repeated requests idempotent. Add regression coverage for notification delivery, deferred publication, rewrite routing, settings, templates, and public request state.

In trunk, for 2.7.

Fixes #3229.

#9 @johnjamesjacoby
3 days ago

In 8353:

Subscriptions: Prime recipient user caches.

Prime subscriber user and user-meta caches in bounded batches before checking notification capabilities. This avoids per-recipient database queries for cold caches while preserving existing access checks, recipient order, and the shared chunk-size filter.

In trunk, for 2.7.

See #3229.

#10 @johnjamesjacoby
3 days ago

In 8358:

Subscriptions: Filter individual email contexts.

Add a filterable per-recipient subscription context before assembling one-click emails. This allows integrations to select the correct subscription object without rewriting completed messages or headers.

Reuse primed user caches when resolving recipient addresses to avoid redundant user queries while preserving batching, ID normalization, multisite behavior, and deduplication.

In trunk, for 2.7.

See #3229.

#11 @johnjamesjacoby
2 days ago

In 8360:

Subscriptions: Identify notification sources.

Generate each receipt from the exact forum, topic, or taxonomy term that caused the notification. Use registered singular labels and object names so integrations can support custom taxonomies without rebuilding completed messages.

Include taxonomy subscribers in new-reply notifications, preserve deterministic post-subscription precedence when sources overlap, and retain topic contexts for recipients added by existing filters. Keep the compatibility helper for user-ID-only callers.

Add regression coverage for built-in and custom taxonomy receipts, new-topic and new-reply delivery, overlapping sources, and filtered subscription contexts.

In trunk, for 2.7.

See #2989, #3229.

#12 @johnjamesjacoby
2 days ago

In 8361:

Notifications: Explain not to reply to emails.

Adapt the existing WordPress.org Meta guidance for bbPress core. Tell subscription and mention email recipients to follow the included link when they want to reply, and clarify that replies sent directly to the notification address are ignored.

Keep this guidance consistent across forum, topic, taxonomy, and mention notifications without changing existing filters or delivery behavior.

In trunk, for 2.7.

See #2773, #3229.

#13 @johnjamesjacoby
44 hours ago

In 8362:

Notifications: Keep line feeds outside translated strings.

Translate each natural-language line separately and assemble plain-text email layouts in PHP. Preserve the rendered moderation, subscription, unsubscribe, and mention messages while avoiding escaped line feeds in translation entries.

In trunk, for 2.7.

See #2773, #2989, #3229, #3349.

Note: See TracTickets for help on using tickets.