ruby on rails - send mail every 5 minutes using delayed job -
this question has answer here:
class testmailer < actionmailer::base def test_mail mail(:to => '(myemailaddress@removedforprivacy.com', :from => '(removedforprivacy)@gmail.com', :subject => 'testing delayed job', :content_type => 'text/plain').deliver
end handle_asynchronously :test_mail, :run_at => proc.new { 2.minutes.from_now }
end
i think want send email every 5 minutes using delayed_job
cron task. can use delayed_cron_job gem accomplish purpose.
you can add: delayed_cron_job
gemfile
, run: bundle install
. then, run:
rails generate delayed_job:cron bundle exec rake db:migrate
then, can use this:
delayed::job.enqueue(delayedemailjob.new(@user.email), cron: '0,5,10,15,20,25,30,35,40,45,50,55 * * * *')
Comments
Post a Comment