Rails 3.0 でメールの送信に Gmail を使う
config/environments/development.rb に以下を書くだけ。
config.action_mailer.default_url_options = { :host => "localhost", :port => 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'example.com',
:user_name => "FOO@example.com",
:password => "PASSWORD",
:authentication => 'plain',
:enable_starttls_auto => true,
}
- Ruby 1.8.7 (2010-06-23 patchlevel 299)、Rails 3.0 RC2 で確認。
- :domain, :user_name, :password は適宜自分のものに変更してください。
- example.com のところは、Google Apps の独自ドメインでもOK。
- require "tlsmail" してる例がWeb上にあるが、enable_starttls_auto をつけただけで大丈夫だった。
- production で使用してもいいが、Google Apps の Gmail は送信数制限(1日200通だっけ?)があるから、別途用意したほうがいいと思う。