Class: ActionMailer::MailDeliveryJob

Inherits:
ActiveJob::Base show all
Defined in:
actionmailer/lib/action_mailer/mail_delivery_job.rb

Overview

Action Mailer MailDeliveryJob

The ActionMailer::MailDeliveryJob class is used when you want to send emails outside of the request-response cycle. It supports sending either parameterized or normal mail.

Exceptions are rescued and handled by the mailer class.

Constant Summary

Constants included from ActiveSupport::Callbacks

ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES

Instance Attribute Summary

Attributes included from ActiveJob::Core

#arguments, #enqueue_error, #enqueued_at, #exception_executions, #executions, #job_id, #locale, #priority, #provider_job_id, #queue_name, #scheduled_at, #serialized_arguments, #successfully_enqueued, #timezone

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Methods included from ActiveJob::Logging

#perform_now

Methods included from ActiveJob::Instrumentation

#perform_now

Methods included from ActiveJob::Exceptions

#retry_job

Methods included from ActiveSupport::Callbacks

#run_callbacks

Methods included from ActiveJob::QueuePriority

#priority

Methods included from ActiveJob::QueueName

#queue_name

Methods included from ActiveJob::Core

#deserialize, #initialize, #serialize, #set, #successfully_enqueued?

Instance Method Details

#perform(mailer, mail_method, delivery_method, args:, kwargs: nil, params: nil) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'actionmailer/lib/action_mailer/mail_delivery_job.rb', line 21

def perform(mailer, mail_method, delivery_method, args:, kwargs: nil, params: nil)
  mailer_class = params ? mailer.constantize.with(params) : mailer.constantize
  message = if kwargs
    mailer_class.public_send(mail_method, *args, **kwargs)
  else
    mailer_class.public_send(mail_method, *args)
  end
  message.send(delivery_method)
end