padrino/padrino-framework · error
mailer '#{mailer_name}' has no message '#{message_name}'
Error message
mailer '#{mailer_name}' has no message '#{message_name}' What it means
deliver resolves the mailer successfully, then looks the second argument up in that mailer's messages hash, which is populated only by email :name blocks declared inside the mailer. A message name with no matching email block raises this error, so the pair (mailer, message) must both be declared before delivering.
Source
Thrown at padrino-mailer/lib/padrino-mailer/helpers.rb:110
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
- Declare the missing message inside the mailer: add email :anniversary do ... end to the mailers :sample block
- Inspect available names with registered_mailers[:sample].messages.keys (or SampleMailer.messages.keys) and correct the call site
- If the message lives in another mailer, deliver via that mailer's name instead
Example fix
# before
deliver(:sample, :anniversary, 'Joey')
# mailer only declares email :birthday
# after — app/mailers/sample.rb
mailers :sample do
email :birthday { ... }
email :anniversary { ... }
end
deliver(:sample, :anniversary, 'Joey') Defensive patterns
Strategy: validation
Validate before calling
mailer = registered_mailers[mailer_name] unless mailer && mailer.messages.key?(message_name) fail mailer_name.to_s + ' has no message ' + message_name.inspect end deliver(mailer_name, message_name, *attributes)
Type guard
def mailer_message_defined?(mailer_name, message_name) registered_mailers[mailer_name.to_sym]&.messages&.key?(message_name.to_sym) end
Prevention
- Keep deliver call sites next to their mailer definitions when refactoring
- Inspect SampleMailer.messages.keys in a console when deliveries fail
- Reload mailers in development after editing message names
When it happens
Trigger: Calling deliver(:sample, :anniversary, ...) when the Sample mailer only declares email :birthday; a message that was defined in a different mailer than the one named; renames or typos on either the email declaration or the deliver call site.
Common situations: Copy-pasting a deliver line and editing only one argument; splitting a large mailer and forgetting to move a message along with it; message names drifting from controller action names during refactoring.
Related errors
- The email '#{name}' is already defined
- mailer '#{mailer_name}' is not registered
- gem 'padrino-helpers' is required to render partials
- To use mailers on Windows you must set a :delivery_method, s
AI-assisted analysis of padrino/padrino-framework@167044f3d5 (2026-08-23).
Data as JSON: /api/errors/852aa5241979d68a.
Report an issue: GitHub.