What's the most elegant way to implement a digest email without reinventing a queueing system?

孤者浪人 提交于 2019-12-03 03:34:57

A digest looks like more appropriate to be done as a cron job like. You would still have to control to "who you have sent", to deal with crashes and errors, but the idea is to run, for example, on a daily basis, a custom rake task that craft your mail message including all info in a digest format and them send or queue for sending.

Obviously you shouldn't have to create your own queueing system. I haven't used delayed_job, but I have used resque in conjunction with a nice little gem called resque_mailer that should do exactly what you want. What's nice about resque_mailer is that, once it's set up, you don't have to change how you'd normally send mail: MyMailer.some_mailing({vars}).deliver If for some reason you want to not use the queue to send the mail (send it right away), you just need to add ! after deliver and it'll do just that.

Look into resque (with redis) and resque_mailer, I think it'll do what you want.

Galen

In case anyone wants more details on a great way to do this, there's a good overview here (second answer): Sending emails based on intervals using Ruby on Rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!