Skip to content

Instantly share code, notes, and snippets.

@carimura
Created June 11, 2012 19:42
Show Gist options
  • Save carimura/2912221 to your computer and use it in GitHub Desktop.
Save carimura/2912221 to your computer and use it in GitHub Desktop.
workers/iron_mailer.rb
# We included ActionMailer and our mailer models in the code package
# in the last step, but we still need to require them in our worker file.
require 'active_support/core_ext'
require 'action_mailer'
require 'models/mailer'
# Parse our config yaml file
config = YAML.load_file("settings.yml")
# A nifty Ruby line to set the AM settings from our loaded yaml file
ActionMailer::Base.smtp_settings = config['sendgrid'].inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
# Since we are building a code package, we need to set the view_path to the
# working directory in order for ActionMailer to find them.
ActionMailer::Base.view_paths = ['.']
# Deliver the email
Mailer.hello_world('[email protected]').deliver!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment