实施电子邮件通知 [英] Implementing Email Notification

查看:130
本文介绍了实施电子邮件通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web应用程序,用户可以创建主题和评论其他主题(类似于我们在这里在stackoverflow)。我想能够向参与讨论的用户发送通知。

I have a web application where users can create topics and also comment on other topics (similar to what we have here on stackoverflow). I want to be able to send notifications to participating users of a discussion.

我知道最简单的方法是将通知挂钩到用户与讨论交互时执行的脚本。尽管这似乎很容易,我相信它不是最适当的方式,因为用户将需要等待直到所有的电子邮件通知(通知脚本完成执行)发送,直到他获得他的行动的状态。

I know the easiest way to go about it is to hook the notification to the script executed when a user interacts with a discussion. In as much as that seems very easy, I believe its not the most appropriate way as the user will need to wait till all the emails notifications (notification script finishes execution) are sent till he gets the status of his action.

我知道的另一个选择是使用cronjob安排通知脚本的执行。为了使通知相关,脚本将安排每3到7分钟执行一次,以确保用户在合理的时间内收到通知。

Another alternative I know of is to schedule the execution of the notification script using cronjob. In order for the notification to be relevant, the script will be scheduled to execute every 3 to 7 minutes so as to make sure the users get notification in a reasonable time.

现在我的关注是,将设置cronjob运行一个脚本每3分钟消耗合理的系统资源考虑我的应用程序仍然在共享托管平台上运行?

Now my concern is, will setting cronjob to run a script every 3 minutes consume reasonable system resource putting into consideration my application is still running on a shared hosting platform?

此外,我认为有可能有一个场景,其中注释脚本将触发或通知通知脚本发送通知到指定的电子邮件地址,而注释脚本继续它的执行无需等待通知脚本的完成。如果这是可以实现的,那么我认为这将是我的最佳选择。

Also, am thinking is it possible to have a scenario where by the comment script will trigger or notify a notification script to send notifications to specified email addresses while the comment script continues it's execution without having to wait for the completion of the notification script. If this can be achievable, then I think it will be the best choice for me.

非常感谢您的时间。

推荐答案

除非你的通知脚本是非常耗费资源的,并且在每次运行时发送数十条或数百条消息,关于在共享主机上每隔3-7分钟调度一次。事实上,如果你安排了3分钟,发现你的网站性能下降,然后增加到4分钟,资源减少25%。

Unless your notification script is enormously resource-intensive and sends dozens or hundreds of messages out on each run, I would not worry about scheduling it every 3-7min on a shared host. Indeed, if you scheduled it for 3 minutes and found performance sagging on your site, then increase it to 4min for a 25% reduction in resources. It's pretty unlikely to be a problem though.

对于启动一个后台进程,你可以通过 exec()的系统调用来实现。 。我会指示您此问题,以获得出色的答案。

As far as starting a background process, you can achieve that with a system call to exec(). I would direct you to this question for an excellent answer.

这篇关于实施电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆