Skip to content

Commit

Permalink
actionmailer for ruby_ng
Browse files Browse the repository at this point in the history
  • Loading branch information
iced committed Feb 23, 2012
1 parent 1de0eec commit 73af6ae
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ruby_ng/actionmailer/actionmailer_runner.rb
@@ -0,0 +1,8 @@
require 'iron_worker_ng'
require 'yaml'

config = YAML.load_file('../../ruby/_config.yml')

client = IronWorkerNG::Client.new(config['iw']['project_id'], config['iw']['token'])

client.tasks.create('ActionmailerWorker', :gmail => config['gmail'], :from => 'andrew@iron.io', :to => ['andrew@iron.io']) # I like receiving mails
14 changes: 14 additions & 0 deletions ruby_ng/actionmailer/actionmailer_uploader.rb
@@ -0,0 +1,14 @@
require 'iron_worker_ng'
require 'yaml'

config = YAML.load_file('../../ruby/_config.yml')

client = IronWorkerNG::Client.new(config['iw']['project_id'], config['iw']['token'])

code = IronWorkerNG::Code::Ruby.new
code.merge_worker 'actionmailer_worker.rb'
code.merge_file 'mailer.rb' # merging mailer...
code.merge_dir 'mailer' # ...and templates
code.merge_gem 'actionmailer' # we need actionmailer gem merged as well

client.codes.create(code)
21 changes: 21 additions & 0 deletions ruby_ng/actionmailer/actionmailer_worker.rb
@@ -0,0 +1,21 @@
require 'action_mailer'
require 'mailer' # current dir is in load path already

# let's configure actionmailer...
ActionMailer::Base.smtp_settings = {
:user_name => @params['gmail']['username'],
:password => @params['gmail']['password'],
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:authentication => 'plain',
:enable_starttls_auto => true
}

ActionMailer::Base.view_paths << '.' # it should know where to look for templates

# ...and deliver some messages
@params['to'].each do |to|
log "Sending mail from #{@params['from']} to #{to}"
Mailer.test_email(@params['from'], to).deliver!
end
5 changes: 5 additions & 0 deletions ruby_ng/actionmailer/mailer.rb
@@ -0,0 +1,5 @@
class Mailer < ActionMailer::Base
def test_email(from, to)
mail(:from => from, :to => to, :subject => "Sample subject")
end
end
1 change: 1 addition & 0 deletions ruby_ng/actionmailer/mailer/test_email.html.erb
@@ -0,0 +1 @@
Here's an email message sent using IronWorker.

0 comments on commit 73af6ae

Please sign in to comment.