背景
- GCE上のRailsアプリでDeviseのメール送信を使いたかった
- 今回はSendGridでメールを送ることに
- Deviseのメール送信できるようにActionMailerを設定
やったこと
- SendGridにアカウント作成
- conf/application.rbに以下の設定を追加した
# deviseのメール設定
config.action_mailer.delivery_method = :smtp
# keyはsesの送信用keyです
config.action_mailer.smtp_settings = {
:user_name => 'ENV['SEND_GRID_ID']',
:password => 'ENV['SEND_GRID_PASS']',
:domain => 'ENV['SOME_DOMAIN']',
:address => 'smtp.sendgrid.net',
:port => 2525,
:authentication => :plain,
:enable_starttls_auto => true
}