未发送设计确认电子邮件

时间:2019-04-22 16:17:18

标签: ruby-on-rails ruby devise sendgrid devise-confirmable

尽管有heroku日志显示,但仍未发送设备帐户确认电子邮件。

我已将send grid附件添加到我的heroku应用程序中。我尝试将config.action_mailer.perform_deliveries = true添加到我的production.rb文件中,并设置config.action_mailer.raise_delivery_errors = true。但是这些似乎都不起作用。

config / environments / production.rb:

  config.action_mailer.perform_caching = false
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'math-scientist.herokuapp.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }

config / initializers / devise.rb

  config.mailer_sender = 'noreply@mathscientist.com'
  config.reconfirmable = false

用户模型:

  class User < ApplicationRecord
    devise :database_authenticatable, :registerable, :confirmable,
       :recoverable, :rememberable, :validatable
  end

数据库迁移:

  class AddConfirmableToUsers < ActiveRecord::Migration[5.1]
    def up
     add_column :users, :confirmation_token, :string
      add_column :users, :confirmed_at, :datetime
      add_column :users, :confirmation_sent_at, :datetime
      add_index :users, :confirmation_token, unique: true
      User.update_all confirmed_at: DateTime.now
    end

    def down
      remove_columns :users, :confirmation_token, :confirmed_at,           
                     :confirmation_sent_at
    end
  end

Heroku日志:

  Sent mail to mathscientistofficial@gmail.com (1210.8ms)
  Date: Mon, 22 Apr 2019 15:51:18 +0000
  From: noreply@mathscientist.com
  Reply-To: noreply@mathscientist.com
  To: mathscientistofficial@gmail.com

  Subject: Confirmation instructions


  <p>Welcome mathscientistofficial@gmail.com!</p>

  <p>You can confirm your account email through the link below:</p>

  <p><a href="http://math-scientist.herokuapp.com/users/confirmation?confirmation_token=sSbZLC3ytX8dEc2Xv1e2">Confirm my account</a></p>

编辑: 我在heroku上检查了sendgrid仪表板,它说没有收到电子邮件请求。

编辑2: 当我添加发送网格附件时,Heroku为我设置了发送网格用户名和密码。但是我没有发送网格API密钥。是否需要发送设计确认电子邮件?

0 个答案:

没有答案