意外と簡単だった
https://gist.github.com/kosaki/9864928
このへん参考にした
stackoverflow: How to send email via smtp with Ruby's mail gem?
http://stackoverflow.com/questions/12884711/how-to-send-email-via-smtp-with-rubys-mail-gem
https://gist.github.com/kosaki/9864928
require 'mail'
Mail.defaults do
options = { :address => "smtp.gmail.com",
:port => 587,
:user_name => 'kosaki.motohiro',
:password => 'パスワード',
:authentication => 'plain',
:enable_starttls_auto => true }
delivery_method :smtp, options
end
mail = Mail.new do
from 'kosaki.motohiro@gmail.com'
to 'kosaki.motohiro@gmail.com'
subject 'ruby mail test'
body 'body'
end
#puts mail.to_s #=> "From: mikel@test.lindsaar.net\r\nTo: you@...
mail.deliver
このへん参考にした
stackoverflow: How to send email via smtp with Ruby's mail gem?
http://stackoverflow.com/questions/12884711/how-to-send-email-via-smtp-with-rubys-mail-gem
コメント