public
Created

SO question

  • Download Gist
congrats.rake
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
namespace :mailers do
desc 'Send the "congrats" mail'
task congrats: :environment do
lists = Photobook.distinct_list_for_date Date.yesterday
 
lists.each do |list|
book = list.most_recent_book
 
if book.present?
mailer = Routines.congrats(book)
mailer.deliver
end
end
end
end
development.rb
Ruby
1 2 3
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = {:host => "localhost:3000"}
Rails.application.routes.default_url_options[:host] = 'localhost:3000'
routines.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
# encoding: utf-8
 
class Routines < ActionMailer::Base
layout 'mailer'
default from: 'someaddr', to: 'anotheraddr'
add_template_helper ApplicationHelper
 
def congrats(photobook)
@photobook = photobook
@user = photobook.user
mail subject: 'test'
end
end
staging.rb
Ruby
1 2 3 4 5 6
Rails.application.routes.default_url_options[:host] = "host"
config.action_mailer.default_url_options = {host: 'samehost'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
# smpt settings here
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.