我正在使用我的自定义邮件程序 UserMailer 发送电子邮件。它在开发中完美运行,但在生产中我得到错误 500,即当我试图在忘记密码时检索我的密码。
这是生产模式下生产日志中的内容
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"✓","authenticity_token"=>"xxxxxxxxxxxxxxx", "user"=>{"email"=>"sam@gmail.com"}, "commit"=>"Send me r$
Completed 500 Internal Server Error in 2ms
NameError (uninitialized constant Devise::UserMailer):
activesupport (3.2.8) lib/active_support/inflector/methods.rb:230:in `block in constantize'
activesupport (3.2.8) lib/active_support/inflector/methods.rb:229:in `each'
activesupport (3.2.8) lib/active_support/inflector/methods.rb:229:in `constantize'
devise (2.1.2) lib/devise.rb:256:in `get'
devise (2.1.2) lib/devise.rb:279:in `mailer'
我的邮件配置。user_mailer.rb
class UserMailer < Devise::Mailer
default :from => "info@xxxxxxxx.com"
def signup_confirmation(user)
@user = user
mail :to => user.email, :subject=> "Thank you for signing with us"
end
# send password reset instructions
def reset_password_instructions(user)
@resource = user
mail(:to => @resource.email, :subject => "Reset password instructions", :tag => 'password-reset', :content_type => "text/html") do |format|
format.html { render "devise/mailer/reset_password_instructions" }
end
end
end
生产.rb 文件
config.action_mailer.default_url_options = { :host => 'https://xxxxxxxxxx.com' }
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'info@xxxxxxxx.com',
:user_name => 'yyyyyy',
:password => 'zzzzzzzz',
:authentication => 'plain',
:openssl_verify_mode => 'none',
:enable_starttls_auto => true
}
您的帮助将不胜感激