2

HerokuアカウントにSendgridを設定しましたが、アプリがメールを送信しようとすると、ログに次の問題が表示されます。

Net :: SMTPFatalError(550指定されたアドレスから受信できません<[config.mailer_senderを使用してdevise.rbで指定した電子メールアドレス]>:認証されていない送信者は許可されていません

私のproduction.rbの設定は次のとおりです。

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = { :host => 'heroku.com' }

  config.action_mailer.smtp_settings = {
    address: "smtp.sendgrid.net",
    port: 587,
    authentication: "plain",
    user_name: ENV["my sendgrid username"],
    password: ENV["my sendgrid password"],
    domain: 'heroku.com'
  }

Sendgridのパスワード/ユーザー名はHerokuから取得されますheroku config -long

問題がどこにあるのかについて誰かが何か提案がありますか?config.mailer_sender認証で定義したメールアドレスを付与するにはどうすればよいですか?

4

1 に答える 1

8

user_nameとpasswordは、値ではなくキー名である必要があります。

config.action_mailer.smtp_settings = {
    address: "smtp.sendgrid.net",
    port: 587,
    authentication: "plain",
    user_name: ENV["SENDGRID_USERNAME"],
    password: ENV["SENDGRID_PASSWORD"],
    domain: 'heroku.com'
  }

構成をコードとは別に保持するという考え方です。

于 2012-02-09T16:22:18.180 に答える