padrino/padrino-framework · error

mailer '#{mailer_name}' is not registered

Error message

mailer '#{mailer_name}' is not registered

What it means

MailerHelpers#deliver looks the first argument up in registered_mailers, a registry filled when mailer classes are defined with the mailers DSL and loaded by the app. If no mailer was ever registered under that name, deliver raises before building any message.

Source

Thrown at padrino-mailer/lib/padrino-mailer/helpers.rb:109

        end
        alias mailers mailer

        ##
        # Delivers a mailer message email with the given attributes.
        #
        # @param [Symbol] mailer_name
        #   The name of the mailer.
        # @param [Symbol] message_name
        #   The name of the message to deliver.
        # @param attributes
        #   The parameters to pass to the mailer.
        #
        # @example
        #   deliver(:sample, :birthday, 'Joey', 21)
        #   deliver(:example, :message, 'John')
        #
        def deliver(mailer_name, message_name, *attributes)
          mailer = registered_mailers[mailer_name] or raise "mailer '#{mailer_name}' is not registered"
          message = mailer.messages[message_name] or raise "mailer '#{mailer_name}' has no message '#{message_name}'"
          message = message.call(*attributes)
          message.delivery_method(*delivery_settings)
          message.deliver
        end

        ##
        # Delivers an email with the given mail attributes with specified and default settings.
        #
        # @param [Hash] mail_attributes
        #   The attributes for this message (to, from, subject, cc, bcc, body, etc.).
        # @param [Proc] block
        #   The block mail attributes for this message.
        #
        # @example
        #   MyApp.email(to: 'to@ma.il', from: 'from@ma.il', subject: 'Welcome!', body: 'Welcome Here!')
        #
        #   # or if you prefer blocks

View on GitHub (pinned to 167044f3d5)

Solutions

  1. Define the mailer with mailers :sample do ... end in app/mailers/sample.rb so the conventional loader picks it up
  2. Inspect what is registered from a console with registered_mailers.keys and match your symbol to it exactly
  3. Fix typos and string/symbol mismatches in the mailer name argument
  4. In Sinatra integration, register Padrino::Mailer and define all mailers before the first deliver call

Example fix

# before
deliver(:samples, :birthday, 'Joey', 21)  # typo: mailer is :sample

# after
deliver(:sample, :birthday, 'Joey', 21)
Defensive patterns

Strategy: validation

Validate before calling

unless registered_mailers.key?(mailer_name)
  fail 'no mailer ' + mailer_name.inspect + ' (registered: ' + registered_mailers.keys.inspect + ')'
end
deliver(mailer_name, message_name, *attributes)

Type guard

def registered_mailer?(name)
  registered_mailers.key?(name.to_sym)
end

Prevention

When it happens

Trigger: Calling deliver(:sample, :birthday, 'Joey', 21) when no mailers :sample block exists anywhere; a typo'd or renamed mailer symbol; the mailer file never loading because it sits outside app/mailers or has a non-matching filename; delivering before the mailer is defined (load order problems, or manual registration in Sinatra integration).

Common situations: Forgetting to place or name the file under app/mailers so Padrino never loads it; renaming a mailer but not its call sites; using padrino-mailer inside Sinatra where mailers must be wired up manually; console sessions started before mailers reload.

Related errors


AI-assisted analysis of padrino/padrino-framework@167044f3d5 (2026-08-23). Data as JSON: /api/errors/f583204debd9fd13. Report an issue: GitHub.