为设计确认电子邮件设置电子邮件消息 ID

Set Email Message ID for Devise confirmation emails

所有的设计确认电子邮件都会进入垃圾邮件文件夹,this question 建议我需要将邮件 ID 设置为默认值 UserMailer。我如何设置设备确认电子邮件的默认值?

这是设置它的代码

require 'digest/sha2'
class UserMailer < ActionMailer::Base
  default "Message-ID" => lambda {"<#{SecureRandom.uuid}@#{Rails.application.config.mailgun_domain}>"}

  # ... the rest of your mailer class
end

修补 DeviseMailer 应该有效

app/mailers/devise_mailer.rb

class DeviseMailer < Devise::Mailer
  default "Message-ID" => lambda {"<#{SecureRandom.uuid}@#{Rails.application.config.mailgun_domain}>"}
  ## ...
end

config/initializers/devise.rb

Devise.setup do |config|
  config.mailer = 'DeviseMailer'
  # ...
end