W3cubDocs

/Padrino

Module: Padrino::Mailer::Helpers::ClassMethods

Overview

Class methods responsible for registering mailers, configuring settings and delivering messages.

Instance Method Summary

Instance Method Details

#deliver(mailer_name, message_name, *attributes) ⇒ Object

Delivers a mailer message email with the given attributes.

Examples:

deliver(:sample, :birthday, "Joey", 21)
deliver(:example, :message, "John")

Parameters:

  • mailer_name (Symbol) — The name of the mailer.
  • message_name (Symbol) — The name of the message to deliver.
  • attributes — The parameters to pass to the mailer.

#email(mail_attributes = {}, &block) ⇒ Object

Delivers an email with the given mail attributes with specified and default settings.

Examples:

MyApp.email(:to => '[email protected]', :from => '[email protected]', :subject => 'Welcome!', :body => 'Welcome Here!')

# or if you prefer blocks

MyApp.email do
  to @user.email
  from "[email protected]"
  subject "Welcome to Awesomeness!"
  body 'path/to/my/template', :locals => { :a => a, :b => b }
end

Parameters:

  • mail_attributes (Hash) (defaults to: {}) — The attributes for this message (to, from, subject, cc, bcc, body, etc.).
  • block (Proc) — The block mail attributes for this message.

#inherited(subclass) ⇒ Object

#mailer(name, &block) ⇒ Object Also known as: mailers

Defines a mailer object allowing the definition of various email messages that can be delivered.

Examples:

mailer :sample do
  email :birthday do |name, age|
    subject 'Happy Birthday!'
    to      '[email protected]'
    from    '[email protected]'
    locals  :name => name, :age => age
    render  'sample/birthday'
  end
end

Parameters:

  • name (Symbol) — The name of the mailer to initialize.

#registered_mailers ⇒ Object

Returns all registered mailers for this application.