Created
January 27, 2015 15:46
-
-
Save sudix/515761b41cc9941d7b73 to your computer and use it in GitHub Desktop.
ses mail sending example.
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 :aws do | |
# http://docs.aws.amazon.com/sdkforruby/api/frames.html | |
# http://qiita.com/itayan/items/112f23cbff13e49cdb53 | |
desc 'send mail' | |
task send_mail: :environment do |_t, _args| | |
ses = Aws::SES::Client.new(region: 'us-west-2') | |
body_text = <<-EOS | |
こんにちは。 | |
このメールはテストメールです。 | |
おしまい | |
EOS | |
subject = 'サブジェクトです' | |
from_email = "no-reply@example.com" | |
to_email = "user@example.com" | |
ses.send_email( | |
source: from_email, | |
destination: { | |
to_addresses: [to_email] | |
}, | |
message: { | |
subject: { | |
data: subject, | |
charset: "UTF-8" | |
}, | |
body: { | |
text: { | |
data: body_text, | |
charset: "UTF-8" | |
} | |
} | |
} | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment