Class: ActionMailer::MailDeliveryJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
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.

Instance Method Summary collapse

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 '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