, ActionMailer 3.0.3. register_template_extension ActionMailer 3.
I use Sinatra. I have mailer.rb (below) in APP_ROOT / lib and the views are in APP_ROOT / views / mailer. It sends an email with the subject, the body is empty, though.
require 'action_mailer'
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.view_paths = File.dirname(__FILE__)+"/../views/"
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'exmaple.com',
:user_name => 'user@exmaple.com',
:password => 'password',
:authentication => 'plain',
:enable_starttls_auto => true }
class Mailer < ActionMailer::Base
def new_comment_notifier(post,comment)
@post = post
@comment = comment
mail(:to => "user@example.com",
:subject => "new comment on: #{post.title}")
end
end
source
share