4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DeviseをSendGridのAPIキーで使うための設定

4
Last updated at Posted at 2018-09-25

サンプルでは、DeviseのSMTP設定にユーザーIDとパスワードを記入すると書いているけど
パスワードは記入したくないので、探したらapiキーでも設定できるよってちょろっと書いていた。

なんてことはなかった。ユーザー名にapikeyの文字を、パスワードには、APIキーを指定する。

config/environment.rbに追記

ActionMailer::Base.smtp_settings = {
  :user_name => 'apikey',
  :password => ENV["SENDGRID_API_KEY"],
  :domain => ENV["DOMAIN"],
  :address => 'smtp.sendgrid.net',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
}

参考
https://sendgrid.kke.co.jp/docs/Tutorials/A_Transaction_Mail/send_transaction_mail.html

4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?