I would like send email with html.erb template and I have some code. Like this:
class Mailer < ActionMailer::Base
def notification(to_email)
begin
mail(to: '[email protected]', subject: "Test message")
rescue Exception => e
return
end
end
end
And some html.erb file:
Hello, <%= @name %>.
But I don't know how to attach this template for my method. Help me please with this issue, because i can't fount normally manual about it.
You can create a page named
notification.html.erb
inapp/views/mailer
directory. You will get all instance variable innotification.html.erb
that is defined in yourdef notification(to_email)
Now
@name
will be available innotification.html.erb
like