Module: Sinatra::Mailer

Included in:
EventContext
Defined in:
lib/diddies/mailer.rb

Overview

You’ll need a simple config like this in your configure block if you want to actually send mail:

Sinatra::Mailer.config = {
  :host   => 'smtp.yourserver.com',
  :port   => '25',              
  :user   => 'user',
  :pass   => 'pass',
  :auth   => :plain # :plain, :login, :cram_md5, the default is no auth
  :domain => "localhost.localdomain" # the HELO domain provided by the client to the server 
}

or 

Sinatra::Mailer.config = {:sendmail_path => '/somewhere/odd'}
Sinatra::Mailer.delivery_method = :sendmail

From your event handlers then, you can just call the ‘email’ method to deliver an email:

email :to => '[email protected]',
      :from => '[email protected]',
      :subject => 'Welcome to whatever!',
      :body => haml(:sometemplate)

Defined Under Namespace

Classes: Email

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



42
43
44
# File 'lib/diddies/mailer.rb', line 42

def config
  @config
end

.delivery_methodObject

Returns the value of attribute delivery_method.



42
43
44
# File 'lib/diddies/mailer.rb', line 42

def delivery_method
  @delivery_method
end

Instance Method Details

#email(mail_options = {}) ⇒ Object



45
46
47
# File 'lib/diddies/mailer.rb', line 45

def email(mail_options={})
  Email.new(mail_options).deliver!
end