Prompt
How do I add unsubscribe handling to app notification emails?
Latest observation
To add unsubscribe handling to app notification emails, the key is to separate transactional emails from marketing/optional notifications, then provide a clear way for users to opt out of the latter.
1) First, classify your emails
Not all emails should have the same unsubscribe behavior:
- Transactional emails: password resets, receipts, security alerts, verification codes
- Usually should not be unsubscribable if they’re required for account/security.
- Notification emails: comments, mentions, weekly digests, feature updates
- These should support unsubscribe or preference controls.
- Marketing emails: promotions, newsletters, campaigns
- Must have easy unsubscribe.
2) Add an unsubscribe link in each email
Include a visible footer link like:
- “Unsubscribe from these emails”
- “Manage email preferences”
For notification emails, prefer preferences over a single global unsubscribe so users can choose categories.
Example footer:
You’re receiving this email because you enabled comment notifications.
[Manage preferences] | [Unsubscribe]
3) Implement preference management
Create a page where users can control:
- All email notifications on/off
- Per-category toggles:
- Comments
- Mentions
- Follows
- Weekly digest
- Product updates
Store this in your database, for example:
{
"userId": "123",
"emailNotifications": {
"comments": true,
"mentions": false,
"digest": true,
"marketing": false
}
}
4) Use a signed unsubscribe token
For security and convenience, don’t require login just to unsubscribe.
Generate a token that encodes:
- user ID
- email category
- expiry (optional)
- signature/HMAC
Example URL:
https://yourapp.com/unsubscribe?token=SIGNED_TOKEN
When clicked:
- validate token
- update unsubscribe settings
- show confirmation page
5) Support one-click unsubscribe where appropriate
For marketing emails, follow email provider and standards best practices:
- Include:
List-Unsubscribeheader- optionally
List-Unsubscribe-Post: List-Unsubscribe=One-Click
This enables Gmail/Apple Mail/etc. to show native unsubscribe controls.
Example headers:
List-Unsubscribe: <https://yourapp.com/unsubscribe?token=...>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
6) Respect unsubscribe immediately
Before sending any email:
- check user preferences
- skip email if category is disabled
- ensure suppression lists are applied
If you use a provider like SendGrid/Mailgun/SES, you can also sync unsubscribes to your provider’s suppression list.
7) Keep critical messages separate
For legal/security reasons:
- Don’t tie password resets and MFA codes to notification unsubscribe settings.
- If a user disables all email notifications, you may still need to send account-critical emails.
8) Add audit/logging
Track:
- when unsubscribe happened
- what category was disabled
- source email/campaign
- token validity issues
This helps debugging and compliance.
9) Recommended UX pattern
Best practice for app notification emails:
- Footer link: Manage preferences
- Secondary link: Unsubscribe from this type of email
- Preferences page with granular toggles
- Confirmation page after update
10) Simple implementation flow
- Email is generated with category and tokenized links
- User clicks unsubscribe/manage preferences
- Server validates token
- Server updates subscription settings
- Future emails are suppressed based on preferences
If you want, I can also show:
- a database schema
- backend code for unsubscribe tokens
- an example for Node.js / Python / Rails
- how to add
List-Unsubscribeheaders for SendGrid/Mailgun/SES