-
Notifications
You must be signed in to change notification settings - Fork 0
How email works
Someone ticks the box, and a subscription is written with the status pending. It does nothing until they click the link in a confirmation email. Until then no notification is ever sent to that address.
For a subscription made with a comment, the confirmation email is not sent until the comment is approved.
This is deliberate. Without it, anybody could post a comment carrying somebody else's address and have your site email them on demand. WordPress holds first-time commenters by default, so on a quiet site most subscriptions sit waiting for a moment.
If a subscription seems stuck, Comments → Subscriptions says which of the two states it is in:
- no confirmation sent yet — usually the comment is still in moderation
- confirmation sent, waiting for the link — the mail went out, the reader has not clicked
There is a Send confirmation now action for pending subscriptions, for when you know the person is genuine and do not want to wait.
Confirmation links last 48 hours (happy_comments_confirmation_lifetime) and work once.
The confirmation is sent at the very end of the request, after the page has already been handed back to the reader. So a slow mail server should not cause any noticeable delays.
Where the server cannot release the connection early — anything that is not PHP-FPM or LiteSpeed — it falls back to a scheduled job instead, so the reader never waits on the mail transport. A scheduled event is also kept as a fallback in both cases, and dropped once a send succeeds.
Notifications about new comments are always queued, in batches of 50.
- Comments on posts that are not published, or are password-protected
- Comments older than 24 hours, which is how imports and migrations are told apart from real activity
- Pingbacks and trackbacks
- The comment's own author, about their own comment
- Anyone already sent a notification about that comment
There is also a cap of 100 comments queued per request, so approving a thousand held comments does not turn into a thousand sends at once.
Every notification carries a link, and these headers:
List-Unsubscribe: <https://example.com/happy-comments/unsubscribe/42/…/>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
which is what makes the unsubscribe button in Gmail and Apple Mail work.
Opening that link in a browser shows a confirmation page with a button. It never unsubscribes on its own, because link scanners and mail gateways follow every URL in an email — a link that acted on being opened would unsubscribe people who never clicked anything.
Unsubscribing keeps the row, marked unsubscribed. It is the record of the opt-out; deleting it would let the next comment from that address resubscribe them as though it never happened.
There is no template editor. Subjects and bodies go through filters — see Hooks — and every mail gets the same set of variables:
All mail: site_name, site_url, subscriber_email, subscription_id, subscription_type, post_id, post_title, post_url, unsubscribe_url
Confirmation adds: confirm_url, confirm_expires_at
Notifications add: comment_id, comment_author, comment_content, comment_url, comment_date
These names are fixed. File-based templates are planned, and once they ship these become something themes depend on.