Ruby Action Mailer:如何发送每日电子邮件?
我只是想知道,在 Ruby on Rails 3 应用程序中,如果我想每天向用户发送一次电子邮件通知,而不是每次都发送通知,我该如何使用 Action Mailer 进行设置?
具体来说,是否有办法在每天下午 6:00 运行邮件程序?
谢谢!
I'm just wondering, in a Ruby on Rails 3 application, if I want to send users an email notification once per day, rather than with every notification, how would I set that up with Action Mailer?
Specifically, would there be a way to run a mailer at, say, 6:00pm every day?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是运行 cron 作业(Linux / Mac 服务器)。使用每当 gem 时这相当简单,它将 cron 作业语法的实际编写抽象为一组方便的 ruby 方法,您可以通过编程方式更改这些方法。
这个 Railscast 很好地解决了这个问题。
One option is to run a cron job (Linux / Mac servers). This is fairly simple with the Whenever gem which abstracts the actual writing of cron job syntax into a convenient set of ruby methods, which you can programmatically change.
This Railscast goes over it pretty well.