Ruby on Rails integration

Transactional email for Rails — beyond ActionMailer

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.

ActionMailer works — until your email matrix explodes

One mailer method per email variation

payment_failed_pro_plan_de is not a joke — it happens when plan and locale branching hits ActionMailer.

ERB templates in your app

Email HTML in views/ means every copy tweak goes through a commit and a deploy pipeline.

No central delivery audit

UserMailer.payment_failed(user).deliver_later scattered across jobs and controllers has no queryable history.

Provider changes ripple through mailers

Switching delivery providers means updating config/environments/ and testing every mailer.

Replace mailer dispatches with event calls

Net::HTTP or Faraday — no gem required

A simple HTTP call from any Rails service object, model callback or background job.

Templates outside your repo

Edit copy in the else.events dashboard. No ERB changes, no capistrano deploy.

Rules match by plan, locale or tenant

Pass plan and locale in the event payload — else.events picks the right template automatically.

Full delivery log

Every event, matched rule and email delivery logged together with domain context.

// Rails — Net::HTTP or Faraday

Send a domain event from any Rails context.

# 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.

Frequently asked questions

Should I use Net::HTTP or Faraday?
Both work. Net::HTTP needs no gem. Faraday is cleaner if you already use it. For background jobs, wrapping the call in a retry-capable job (Sidekiq, GoodJob) is recommended.
Can I use this in Active Job?
Yes. Create an ElseEventsJob that calls EmailService.send_event and enqueue it instead of dispatching a mailer. This gives you retries and observability via your job queue.
How do I set the API key?
Add ELSE_EVENTS_API_KEY to your .env (or credentials.yml.enc). Reference it via ENV or Rails.application.credentials.
Can I migrate from ActionMailer incrementally?
Yes. Keep existing ActionMailer calls for now and replace them one by one as you create templates in else.events.

Rails email — without a mailer class per variation.

One service call per event type. Templates managed outside your repository.

  • No gem dependency
  • Works with Sidekiq and GoodJob
  • Templates editable without deploys