我无法获得邮戳来处理注册和忘记密码的电子邮件:
user_mailer.rb
class UserMailer < ActionMailer::Base
include Devise::Mailers::Helpers
default from: "donotreply@barnpix.com"
def confirmation_instructions(record)
devise_mail(record, :confirmation_instructions)
end
def reset_password_instructions(record)
devise_mail(record, :reset_password_instructions)
end
def unlock_instructions(record)
devise_mail(record, :unlock_instructions)
end
# you can then put any of your own methods here
end
应用程序.rb
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { :api_key => ENV['9302106a-63xxxx-xxx-xx-'] }
用户.rb
devise :database_authenticatable, :registerable, :recoverable,
:rememberable, :trackable, :validatable
devise.rb
config.mailer = "UserMailer" # UserMailer is my mailer class
我根本无法让它工作。关于我可能做错了什么或我可能错过了什么才能让它工作的任何提示?
我认为您的问题是由以下行引起的:
config.action_mailer.postmark_settings = { :api_key => ENV['9302106a-63xxxx-xxx-xx-'] }
ENV
是所有环境变量的哈希。应使用名称来访问值。我猜你在 Heroku 上使用邮戳,所以在这种情况下它会ENV['POSTMARK_API_KEY']
。