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

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

问题描述

我有一个Web应用程序,用户可以在其中创建主题,并对其他主题进行评论(类似于我们在stackoverflow中的内容)。我想能够向参与讨论的用户发送通知。



我知道最简单的方法是将通知挂起到用户与讨论交互时执行的脚本。尽管看起来很简单,但我相信它不是最合适的方式,因为用户需要等到发送所有的电子邮件通知(通知脚本完成执行)才能获得他的动作状态。



我知道的另一种方法是使用cronjob来调度通知脚本的执行。为了使通知相关,脚本将按每3到7分钟执行一次,以确保用户在合理的时间内获得通知。



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



另外,我认为有可能有一种情况,即注释脚本将触发或通知通知脚本将通知发送到指定的电子邮件地址,同时注释脚本继续它的执行无需等待通知脚本的完成。如果这是可以实现的,那么我认为这将是我的最佳选择。



非常感谢你的时间。

解决方案

除非您的通知脚本非常耗费资源,每次运行都会发送数十或数百条消息,否则我不用担心关于在共享主机上每3-7分钟安排一次。事实上,如果你安排了3分钟,发现你的网站上出现性能下滑,那么将其增加到4分钟,资源减少25%。这是不太可能成为一个问题。



只要启动后台进程,您可以通过系统调用 exec() 。我会指示您此问题获得极好的答案。


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.

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.

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.

Thank you very much for your time.

解决方案

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.

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天全站免登陆