0

这是一个特别奇怪的问题……我使用 Devise,当我要求重设密码时,我想收到电子邮件。

所以我将此行添加到我的 development.rb 文件中:

ActionMailer::Base.default_url_options[:host] = "localhost:3000"

这很好用...

但是,如果我更改地址并在其中写一些带有点的内容,例如我的生产地址“xxx.herokuapp.com”,则不会发送邮件。我没有收到任何错误,在日志中我看到一条消息,告诉我邮件已发送,但我什么也没收到。

如果我提供的主机名中没有点 ('.'),我只会收到一封电子邮件。


编辑

如果我使用默认的 Devise:Mailer,一切正常。我的自定义邮件程序一定有问题。

这是:Mailer.rb

class Mailer < Devise::Mailer

  include Devise::Mailers::Helpers

  def headers_for(action, opts={})
    headers = {
        :subject       => t("devise.mailer.#{action}.subject"),
        :from          => mailer_sender(devise_mapping),
        :to            => resource.email,
        :bcc           => "myadresse",
        :template_path => template_paths
    }
  end

  def confirmation_instructions(record, opts={})
    devise_mail(record, :confirmation_instructions, opts)
  end

  def reset_password_instructions(record, opts={})
    devise_mail(record, :reset_password_instructions, opts)
  end

  def unlock_instructions(record, opts={})
    devise_mail(record, :unlock_instructions, opts)
  end

end
4

1 回答 1

0

正如这里所解释的,你可能必须这样super打电话

def headers_for(action, opts={})
    headers = super.merge({
        :subject       => t("devise.mailer.#{action}.subject"),
        :from          => mailer_sender(devise_mapping),
        :to            => resource.email,
        :bcc           => "myadresse",
        :template_path => template_paths
    })
end
于 2013-06-26T13:17:13.983 回答