module Tennpipes::Mailer
This component uses the mail
library to create a powerful but simple mailer within Tennpipes
(and Sinatra). There is full support for using plain or html content-types as well as for file attachments.
Using the mailer in Tennpipes
has two forms. The 'quick' method requires only use of the email
method directly in the controller:
# app/controllers/session.rb post :create do email do from "tony@reyes.com" to "john@smith.com" subject "Welcome!" body render('email/registered') end end
Public Class Methods
registered(app)
click to toggle source
Registers the Tennpipes::Mailer
helpers with the application.
@param [Sinatra::Application] app The application that needs mailers.
@example
require 'tennpipes-mail' class Demo < Tennpipes::Application register Tennpipes::Mailer::Helpers end
# File lib/tennpipes-mail.rb, line 39 def registered(app) require 'tennpipes-mail/base' require 'tennpipes-mail/helpers' require 'tennpipes-mail/mime' # This lazily loads the mail gem, due to its long require time. app.set :_tennpipes_mailer, proc { require 'tennpipes-mail/ext' app._tennpipes_mailer = Mail } app.helpers Tennpipes::Mailer::Helpers end
Also aliased as: included