Class: ActionMailer::MailDeliveryJob

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

Overview

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



16
17
18
19
20
21
22
23
24
# File 'lib/action_mailer/mail_delivery_job.rb', line 16

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