Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 mail with delay

I'm continuing my migration from rails 2.3.12 to 3.0.9 and am now working sending email notifications through Gmail.

I followed the Railscast and I can now send emails properly in my rails 3.0 app when I do:

Mailer.test_html(email).deliver

But I can't figure out how to send them as a background task. In my rails 2.3 app, I used to use the delayed_job_mailer plugin to send emails as a background task. I now deleted the plugin. I also installed a newer version of the delayed_job gem (2.1.4). But, the

Mailer.delay.test_html(email)

command doesn't send the email on my development machine. In the logs, I can see the matching task being inserted in the delayed_jobs table. But I don't know when the task is being treated and deleted from the delayed_jobs table... and I don't receive any email.

In my development.rb file, I have:

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

but I'm not even sure if this is really useful. Any idea about what I'm missing?

like image 362
alex Avatar asked Mar 10 '26 01:03

alex


1 Answers

You need to run the rake jobs:work task to have a process by Delayed Job work off jobs from that table. Without this, you will not receive any emails.

like image 184
Ryan Bigg Avatar answered Mar 13 '26 18:03

Ryan Bigg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!