Prompt
How do I send comment notification emails?
Latest observation
Sep 23, 2026
OpenAI APIWeb search: off
To send comment notification emails, you generally need to:
-
Detect when a comment is created
- Trigger an event/hook when a new comment is posted.
-
Figure out who should be notified
- Common recipients:
- The post/article author
- Anyone who previously commented
- Users who explicitly subscribed to notifications
- Common recipients:
-
Generate the email content
- Include:
- Comment text
- Who posted it
- A link back to the thread
- An unsubscribe/manage preferences link if applicable
- Include:
-
Send the email through an email service
- Use SMTP or a transactional email provider like:
- SendGrid
- Mailgun
- Amazon SES
- Postmark
- Avoid sending directly from your app server if possible, since deliverability is usually worse.
- Use SMTP or a transactional email provider like:
-
Prevent duplicate or excessive notifications
- Don’t notify the commenter themselves unless desired
- Deduplicate recipients
- Consider batching or rate-limiting notifications for busy threads
-
Handle preferences and compliance
- Store opt-in/opt-out settings
- Include unsubscribe links if required
- Follow email laws/requirements in your region
Typical flow
- User submits a comment
- Backend saves it
- Backend emits
comment.created - Notification service finds subscribers
- Notification service sends emails asynchronously via a queue/job worker
Example pseudo-logic
onCommentCreated(comment):
recipients = getNotifyRecipients(comment.thread)
recipients = remove(comment.author, recipients)
for user in recipients:
sendEmail(user.email, template("new comment", comment))
If you want, I can show you how to implement this in a specific stack like:
- WordPress
- Django
- Laravel
- Node/Express
- Rails
- PHP
- Firebase/Firestore