One mailer method per email variation
payment_failed_pro_plan_de is not a joke — it happens when plan and locale branching hits ActionMailer.
Ruby on Rails integration
POST a domain event from any Rails model, job or controller. else.events handles routing, template rendering and delivery — no mailer class per email type.
payment_failed_pro_plan_de is not a joke — it happens when plan and locale branching hits ActionMailer.
Email HTML in views/ means every copy tweak goes through a commit and a deploy pipeline.
UserMailer.payment_failed(user).deliver_later scattered across jobs and controllers has no queryable history.
Switching delivery providers means updating config/environments/ and testing every mailer.
A simple HTTP call from any Rails service object, model callback or background job.
Edit copy in the else.events dashboard. No ERB changes, no capistrano deploy.
Pass plan and locale in the event payload — else.events picks the right template automatically.
Every event, matched rule and email delivery logged together with domain context.
// Rails — Net::HTTP or Faraday
# app/services/email_service.rb
class EmailService
API_URL = "https://app.else.events/api/events".freeze
def self.send_event(type:, user:, data: {})
uri = URI(API_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
"Authorization" => "Bearer #{ENV['ELSE_EVENTS_API_KEY']}",
"Content-Type" => "application/json"
})
request.body = { type: type, user: user, data: data }.to_json
http.request(request)
end
end
# Usage in a job
EmailService.send_event(
type: "invoice.payment_failed",
user: { email: invoice.user.email, name: invoice.user.name },
data: { plan: invoice.plan, amount: invoice.amount.to_s, currency: "EUR",
update_payment_url: billing_url }
)No gem dependency. The service class is a thin wrapper around a standard HTTP call. Inject or call it from jobs, model callbacks or controllers.
One service call per event type. Templates managed outside your repository.