I have a rails app with actionmailer that sends reminders to customers. So I want to have emails sent at specific datetimes. How can I do that, or any action from the controller?
Asked
Active
Viewed 5,173 times
1 Answers
12
You can achieve this goal by using some kind of background tasks like resque or delayed_job for example.
Also, gems like whenever (Cron jobs in Ruby) would help you get there!
Take a look at this tutorial which shows sending emails with a Background Processor through Active Job and delayed_job
Update
To send emails at specific date time, you could use deliver_later with the wait_until
option.
Notifier.welcome(User.first).deliver_later(wait_until: 10.hours.from_now)

K M Rakibul Islam
- 33,760
- 12
- 89
- 110
-
The edit is exactly what i was looking for, much appreciated. Can the "deliver_later" option be edited if the time is incorrect? – Suavocado Aug 31 '15 at 18:13
-
sorry, I did not understand your question, could you please rephrase? – K M Rakibul Islam Aug 31 '15 at 18:24
-
1So say I have called the "deliver later" action. Can i intercept it if I find out the time is incorrect before the message is sent? – Suavocado Aug 31 '15 at 23:24