Forum: Ruby on Rails Sending mail (ActionMailer) after a delay

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ajay K. (Guest)
on 2007-03-12 18:55
Hi,

I'd like my app to be able to send an email off at a predetermined time
after a given contoller action occurs.

Oh, and I'd like to be able to change this time on the fly (ie, reset
the timer) if the controller action is called again before the original
time is reached.

Does anyone know of a good way to do this?

Thanks a lot.
Gwyn Morfey (Guest)
on 2007-03-12 19:46
(Received via mailing list)
Have a look at BackgrounDrb. Essentially you'd do something like
send_me_later = DeferredMail.new(:send_after=>2.hours.from_now), then
a BackgrounDrb worker would scan the table every minute and send mail
as needed. The controller could always destroy the DeferredMail object
before it was sent, if you needed to cancel the operation.

Gwyn.
http://gwyn.dezyne.net/
Ajay K. (Guest)
on 2007-03-13 04:39
Thanks Gwyn.  I'll give that a shot.
This topic is locked and can not be replied to.