Sha256: 8a1578d09ba0c2965e6e3f8e2a989b8a8c5fd80fbf1e20168d4c2809d5cfa421

Contents?: true

Size: 1.2 KB

Versions: 43

Compression:

Stored size: 1.2 KB

Contents

require 'sinatra/base'
require 'sinatra_more'
require 'haml'

class MailerDemo < Sinatra::Base
  configure do
    set :root, File.dirname(__FILE__)
    set :smtp_settings, {
      :host   => 'smtp.gmail.com',
      :port   => '587',
      :tls    => true,
      :user   => 'user',
      :pass   => 'pass',
      :auth   => :plain
   }
  end
  
  register SinatraMore::MailerPlugin
  
  class SampleMailer < SinatraMore::MailerBase    
    def birthday_message(name, age)
      subject "Happy Birthday!"
      to   'john@fake.com'
      from 'noreply@birthday.com'
      body 'name' => name, 'age' => age
      via  :smtp
    end
    
    def anniversary_message(names, years_married)
      subject "Happy anniversary!"
      to   'julie@fake.com'
      from 'noreply@anniversary.com'
      body 'names' => names, 'years_married' => years_married
      type 'html'
    end
  end
  
  post "/deliver/plain" do
    result = SampleMailer.deliver_birthday_message("Joey", 21)
    result ? "mail delivered" : 'mail not delivered'
  end
  
  post "/deliver/html" do
    result = SampleMailer.deliver_anniversary_message("Joey & Charlotte", 16)
    result ? "mail delivered" : 'mail not delivered'
  end
end

class MailerUser
  
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
sinatra_more-0.3.43 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.42 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.41 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.40 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.39 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.38 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.37 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.36 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.35 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.34 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.33 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.32 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.31 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.30 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.29 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.28 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.27 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.26 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.25 test/fixtures/mailer_app/app.rb
sinatra_more-0.3.24 test/fixtures/mailer_app/app.rb