forked from frommww/iron_worker_examples
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Mailer < ActionMailer::Base | ||
def test_email(from, to) | ||
mail(:from => from, :to => to, :subject => "Sample subject") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Here's an email message sent using IronWorker. |