Я придумал самодельный дизайн для этого:
class ApplicationMailer < ActionMailer::Base
before_action do
@layout = 'mailer'
@from = 'default@domain.com'
@to = 'default_to@domain.com'
@subject = 'Default Subject'
@domain = 'default.domain.com'
@params = {}
end
after_action do
ac = ActionController::Base.new()
mg = Mailgun::Client.new 'key-xxxxxxxxx'
message_params = {
from: @from,
to: @to,
subject: @subject,
text: ac.render_to_string("#{self.class.to_s.underscore}/#{action_name}.text", layout: @layout, locals: @params),
html: ac.render_to_string("#{self.class.to_s.underscore}/#{action_name}.html", layout: @layout, locals: @params)
}
mg.send_message @domain, message_params
end
end
class UserMailer < ApplicationMailer
before_action do
@from = 'Domain <updates@domain.com>'
@domain = 'updates.domain.com'
end
def test
@to = "yourself@gmail.com"
@subject = "Test"
@params = {}
end
end
Настройте user_mailer/test.txt.erb
и user_mailer/test.html.erb
и отправьте электронное письмо:
UserMailer.test