Rails设计电子邮件身份验证错误

时间:2016-04-05 13:21:18

标签: ruby-on-rails authentication devise

我是rails的新手,我正在使用rails devise模板应用程序。当我输入我的电子邮件并尝试重置密码时,我收到以下错误:authentication required

enter image description here

这是什么意思?

更新:正如trh所建议的那样,错误来自secrets.yml 以下是目前的情况:

development:
admin_name: Ben
admin_email: admin@exmaple.com
admin_password: password
email_provider_username: "username@gmail.com" #eg. ben@gmail.com
email_provider_password: "password"
domain_name: example.com
secret_key_base: #30 digit code

错误是否可能来自我声明电子邮件提供商用户名和密码的方式?它需要采用<%= ENV["GMAIL_USERNAME"] %>形式吗?

1 个答案:

答案 0 :(得分:1)

您的邮件配置完成于:config/environments/development.rb

由于RailsApps模板已经为gmail设置了该模板,因此您需要更改config/secrets.yml中的数据(用户名,密码等)。如果您打算使用SMTP(对于非谷歌地址),那么您需要更改您的development.rb文件以匹配该文件。例如,您将不得不更改域名主机,因此如果您的邮件提供商是outlook.com,那么您的配置将如下所示:

config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
 :address              => "smtp.live.com",
 :port                 => 587,
 :enable_starttls_auto => true,
 :user_name            => 'noreply@example.com',
 :password             => 'password',
 :domain               => 'example.com',
 :authentication       => 'plain'
}