<p>I really like the idea of using a simple plugin like Like to keep track of what entries users are interested in.</p>

<p>But instead of writing the code to integrate with Postmaster, I’d probably just use Craft’s API directly to send the mail after new entries are saved in your comments section.</p>

<p>The Like plugin and Craft API you need to look into:</p>

<ul>
<li><a href="https://craftcms.com/docs/plugins/events-reference#entries-onSaveEntry" rel="nofollow"><code>entries.onSaveEntry</code> event</a></li>
<li><a href="https://github.com/dukt/craft-like/blob/1.0.0/services/LikeService.php#L109" rel="nofollow"><code>getLikesByElementId()</code></a></li>
<li><a href="https://craftcms.com/classreference/services/EmailService#sendEmailByKey-detail" rel="nofollow"><code>sendEmailByKey()</code></a></li>
</ul>

CC BY-SA 3.0
2016-07-23T20:21:15.110Z
You're right, I don't need the Postmaster plugin. Thank you!
MISC
CC BY-SA 3.0
2016-07-23T17:34:04.000Z
2016-07-23T17:34:04.000Z
carlcs
<p>Just a further update on this project:</p>

<p>I was now able to create a task for each notification email. This makes the onSaveEntry event much faster, because emails are now processed in the background. This makes it possible to use sendEmailByKey() instead of a third party API, which reduces the maintenance effort.</p>

<p>Creating tasks was much easier than expected (based on the <a href="https://github.com/pixelandtonic/PowerNap" rel="nofollow">PowerNap</a> plugin). </p>

CC BY-SA 3.0
2016-08-02T09:16:29.147Z
Very good idea to use tasks, and I also agree with the `sendEmailByKey` decision!
carlcs
CC BY-SA 3.0
2016-08-02T09:14:44.343Z
2016-08-02T09:14:44.343Z
MISC
<p>Just wanted to give a short update on this project:</p>

<p>I was able to build this plugin. The only problem was, that sendEmailByKey() took a lot of time and delayed the saving process extremely (probably because of the slow sending by SMTP). So I've decided to replace SMTP by the Sparkpost API which allows to use templates in a similar way than sendEmailByKey. This solution is faster than the SMTP one. But I am afraid that with a bigger amount of followers the thing will become slow again.</p>

<p>In general, I am of the opinion, that doing email notification as part of the onSaveEntry event is probably not the best solution. Background tasks could be interesting, but I was not yet able to understand the Craft CMS TaskService ...</p>

CC BY-SA 3.0
2017-04-05T03:53:07.900Z
I don't suppose you can share the plugin? :-)
Ryan
CC BY-SA 3.0
2016-07-30T08:35:25.623Z
2016-07-30T10:04:06.633Z
2016-07-30T10:04:06.633Z
MISC
<p>I am thinking about a possibility to let members subscribe to a blog entry, and then get notified in case of new comments related to the respective entry. The comments are stored as entries in a Craft CMS channel.</p>

<p>My idea is to use the <a href="https://github.com/dukt/craft-like" rel="nofollow">Like for Craft CMS</a> plugin for the subscription to a blog entry. In a second step I would try to use the <a href="https://github.com/objectivehtml/Postmaster-for-Craft-CMS" rel="nofollow">Postmaster for Craft CMS</a> plugin to notify the subscribers by email. I hope that this will be possible using the <a href="https://github.com/objectivehtml/Postmaster-for-Craft-CMS/wiki/Developer-API" rel="nofollow">Postmaster Developer API</a>, but I am not sure.</p>

<p>What is your opinion regarding my idea? Do you know perhaps an easier approach.</p>

<p>I very much appreciate your help, thanks!</p>

<emails><comments>
How to subscribe to an entry and get notified by email in case of new comments?
# How to subscribe to an entry and get notified by email in case of new comments?

(Asked by: username_0 on 2016-07-23)

I am thinking about a possibility to let members subscribe to a blog entry, and then get notified in case of new comments related to the respective entry. The comments are stored as entries in a Craft CMS channel.

My idea is to use the [Like for Craft CMS](https://github.com/dukt/craft-like) plugin for the subscription to a blog entry. In a second step I would try to use the [Postmaster for Craft CMS](https://github.com/objectivehtml/Postmaster-for-Craft-CMS) plugin to notify the subscribers by email. I hope that this will be possible using the [Postmaster Developer API](https://github.com/objectivehtml/Postmaster-for-Craft-CMS/wiki/Developer-API), but I am not sure.

What is your opinion regarding my idea? Do you know perhaps an easier approach.

I very much appreciate your help, thanks!

**Tags:** emails, comments

---

## 3 answers

### Answer by username_1 on 2016-07-23. Score: 3 | Accepted answer

I really like the idea of using a simple plugin like Like to keep track of what entries users are interested in.

But instead of writing the code to integrate with Postmaster, I’d probably just use Craft’s API directly to send the mail after new entries are saved in your comments section.

The Like plugin and Craft API you need to look into:

* [`entries.onSaveEntry` event](https://craftcms.com/docs/plugins/events-reference#entries-onSaveEntry)
* [`getLikesByElementId()`](https://github.com/dukt/craft-like/blob/1.0.0/services/LikeService.php#L109)
* [`sendEmailByKey()`](https://craftcms.com/classreference/services/EmailService#sendEmailByKey-detail)

> **Comments:**
> **username_0**: You're right, I don't need the Postmaster plugin. Thank you!  

---

### Answer by username_0 on 2016-08-02. Score: 2

Just a further update on this project:

I was now able to create a task for each notification email. This makes the onSaveEntry event much faster, because emails are now processed in the background. This makes it possible to use sendEmailByKey() instead of a third party API, which reduces the maintenance effort.

Creating tasks was much easier than expected (based on the [PowerNap](https://github.com/pixelandtonic/PowerNap) plugin).

> **Comments:**
> **username_1**: Very good idea to use tasks, and I also agree with the `sendEmailByKey` decision!  

---

### Answer by username_0 on 2016-07-30. Score: 2

Just wanted to give a short update on this project:

I was able to build this plugin. The only problem was, that sendEmailByKey() took a lot of time and delayed the saving process extremely (probably because of the slow sending by SMTP). So I've decided to replace SMTP by the Sparkpost API which allows to use templates in a similar way than sendEmailByKey. This solution is faster than the SMTP one. But I am afraid that with a bigger amount of followers the thing will become slow again.

In general, I am of the opinion, that doing email notification as part of the onSaveEntry event is probably not the best solution. Background tasks could be interesting, but I was not yet able to understand the Craft CMS TaskService ...

> **Comments:**
> **username_2**: I don't suppose you can share the plugin? :-)  

---

