As the title says, but I'm a little addicted to it, so make a note
I wanted to skip the mail when the job execution was completed, so I implemented it as follows
XxxxJob.rb
Mailer.send_mail(user).deliver_later
So, lightly check the operation ... Check the log to see if it's in the queue, I ran the above in rails console and saw it in letter_opener
When I put it in the verification environment, I didn't get an email ...
I couldn't figure it out even if I debugged various things, and I couldn't find it in the internet search.
In general, asynchronous queues (such as sending mail with .deliver_later) will not work if you write them in a Rake task. This is because when Rake finishes, .deliver_later may drop the in-process thread pool before it finishes processing the mail. To work around this issue, use .deliver_now or run a persistent queue in the development environment.
https://railsguides.jp/active_job_basics.html#action-mailer
It was written to the fullest orz When I set it to deliver_now, the mail flew without incident
XxxxJob.rb
Mailer.send_mail(user).deliver_now
By the way, I chose deliver_later
because the existing process is like that, and I think it's better to be asynchronous.
So, use deliver_now
when skipping emails from a job
Recommended Posts