Skip to content

Instantly share code, notes, and snippets.

@sudix
Created January 27, 2015 15:46
Show Gist options
  • Save sudix/515761b41cc9941d7b73 to your computer and use it in GitHub Desktop.
Save sudix/515761b41cc9941d7b73 to your computer and use it in GitHub Desktop.
ses mail sending example.
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