Created
August 17, 2012 07:39
-
-
Save ksol/3376803 to your computer and use it in GitHub Desktop.
SO question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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