diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/message_delivery.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/message_delivery.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/message_delivery.rb b/actionmailer/lib/action_mailer/message_delivery.rb index cf7c57e6bf..a2ea45dc7b 100644 --- a/actionmailer/lib/action_mailer/message_delivery.rb +++ b/actionmailer/lib/action_mailer/message_delivery.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require "delegate" module ActionMailer # The <tt>ActionMailer::MessageDelivery</tt> class is used by - # <tt>ActionMailer::Base</tt> when creating a new mailer. + # ActionMailer::Base when creating a new mailer. # <tt>MessageDelivery</tt> is a wrapper (+Delegator+ subclass) around a lazy # created <tt>Mail::Message</tt>. You can get direct access to the # <tt>Mail::Message</tt>, deliver the email or schedule the email to be sent @@ -51,6 +53,14 @@ module ActionMailer # Notifier.welcome(User.first).deliver_later!(wait: 1.hour) # Notifier.welcome(User.first).deliver_later!(wait_until: 10.hours.from_now) # + # By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each + # <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable + # +delivery_job+. + # + # class AccountRegistrationMailer < ApplicationMailer + # self.delivery_job = RegistrationDeliveryJob + # end + # # Options: # # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay @@ -67,6 +77,14 @@ module ActionMailer # Notifier.welcome(User.first).deliver_later(wait: 1.hour) # Notifier.welcome(User.first).deliver_later(wait_until: 10.hours.from_now) # + # By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each + # <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable + # +delivery_job+. + # + # class AccountRegistrationMailer < ApplicationMailer + # self.delivery_job = RegistrationDeliveryJob + # end + # # Options: # # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay. @@ -118,7 +136,8 @@ module ActionMailer "method*, or 3. use a custom Active Job instead of #deliver_later." else args = @mailer_class.name, @action.to_s, delivery_method.to_s, *@args - ::ActionMailer::DeliveryJob.set(options).perform_later(*args) + job = @mailer_class.delivery_job + job.set(options).perform_later(*args) end end end |