You can specify which queue to use when calling deliver_later in an ActionMailer by adding :queue as optional argument, e.g.:
Notifier.welcome(User.first.id).deliver_later(queue: "low")
Is there a way to do this in a general way, for all ActionMailers? To set the default ActionMailer queue?
Looking through Rails' source code you can see that they already set the default queue name as 'mailers'.
Still, if you want to change that default you can always override it by including the following code in an initialiser or loaded lib file:
class ActionMailer::DeliveryJob queue_as :default_mailer_queue end
Rails 5 allows you to set the default queue naming by simply configuring it.
E.g. add to you application.rb
:
config.action_mailer.deliver_later_queue_name = 'default_mailer_queue'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With