Mateusz Urbański
Mateusz Urbański

Reputation: 7862

Choose specific email template with ActionMailer

I have a problem with choosing specific email template. I have the following mailer:

class NewsletterMailer < ActionMailer::Base
  def confirmation_email(subscriber)
    @subscriber = subscriber

    mail(to: @subscriber.email,
         subject: t('.confirmation_subject'))
  end
end

And two emails templates that are stored in app/views/newsletter_mailer:

Is there any way to set in this mailer action to use this: "confirmation_email.en.html.erb"?

Thanks in advance for any help.

Upvotes: 1

Views: 321

Answers (1)

RAJ
RAJ

Reputation: 9747

Try this:

mail(to: @subscriber.email,
         template_name: 'confirmation_email.en.html.erb',
         subject: t('.confirmation_subject'))

You may read more at Mailer Views

Upvotes: 1

Related Questions