サンプルでは、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