Skip to content

Instantly share code, notes, and snippets.

@ksol
Created August 17, 2012 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksol/3376803 to your computer and use it in GitHub Desktop.
Save ksol/3376803 to your computer and use it in GitHub Desktop.
SO question
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
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'
# 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
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment