LoginSignup
2
1

More than 5 years have passed since last update.

GCEからSendGrid使ってActionMailerでメールを送信する方法

Last updated at Posted at 2017-03-06

背景

  • 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
    }
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1