Sha256: a5b3893c7241644fb45b911e9973fa1fe02e78d8933b344f4f36fcc9511d46d9

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

require 'sinatra/base'

class SinatraApp < Sinatra::Base
  register Padrino::Mailer

  set :root, File.dirname(__FILE__)
  set :delivery_method, :test

  mailer :sample do
    email :birthday do |name, age|
      subject "Happy Birthday!"
      to      'john@fake.com'
      from    'noreply@birthday.com'
      locals  :name => name, :age => age
      via     :test
      render  'sample/birthday'
    end

    email :anniversary do |names, years_married|
      subject "Happy anniversary!"
      to   'julie@fake.com'
      from 'noreply@anniversary.com'
      locals :names => names, :years_married => years_married
      content_type :html
      via  :test
      render 'sample/anniversary'
    end

    message :welcome do |name|
      subject "Welcome Message!"
      to      'john@fake.com'
      from    'noreply@custom.com'
      locals  :name => name
      via     :test
      render  'sample/foo_message'
    end
  end

  post "/deliver/inline" do
    result = email(:to => "john@apple.com", :from => "joe@smith.com", :subject => "Test Email", :body => "Test Body", :via => :test)
    result ? "mail delivered" : 'mail not delivered'
  end

  post "/deliver/plain" do
    result = deliver(:sample, :birthday, "Joey", 21)
    result ? "mail delivered" : 'mail not delivered'
  end

  post "/deliver/html" do
    result = deliver(:sample, :anniversary, "Joey & Charlotte", 16)
    result ? "mail delivered" : 'mail not delivered'
  end

  post "/deliver/custom" do
    result = deliver(:sample, :welcome, "Bobby")
    result ? "mail delivered" : 'mail not delivered'
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
padrino-mailer-0.16.0.pre3 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.16.0.pre2 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.15.3 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.15.2 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.15.1 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.15.0 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.4 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.3 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.2 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.1.1 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.1 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.0.2 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.0.1 test/fixtures/sinatra_app/app.rb
padrino-mailer-0.14.0 test/fixtures/sinatra_app/app.rb