问题
I am running into an issue with mailing password resets from my Ruby on Rails application. The password reset mailing used to work, however, now it does not. Password resets are the only emails that the server sends. Once I submit the email that I'd like to get a password for, Rails displays this on full trace:
EOFError in Devise::PasswordsController#create end of file reached
Rails.root: /home/path/to/app
/usr/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock'
/usr/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock'
/usr/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
/usr/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
/usr/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
/usr/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
/usr/lib/ruby/1.9.1/net/smtp.rb:915:in `block in getok'
/usr/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
/usr/lib/ruby/1.9.1/net/smtp.rb:913:in `getok'
/usr/lib/ruby/1.9.1/net/smtp.rb:907:in `quit'
/usr/lib/ruby/1.9.1/net/smtp.rb:613:in `do_finish'
/usr/lib/ruby/1.9.1/net/smtp.rb:522:in `ensure in start'
/usr/lib/ruby/1.9.1/net/smtp.rb:522:in `start'
mail (2.5.4) lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
mail (2.5.4) lib/mail/message.rb:2129:in `do_delivery'
mail (2.5.4) lib/mail/message.rb:232:in `block in deliver'
actionmailer (4.1.1) lib/action_mailer/base.rb:527:in `block in deliver_mail'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionmailer (4.1.1) lib/action_mailer/base.rb:525:in `deliver_mail'
mail (2.5.4) lib/mail/message.rb:232:in `deliver'
devise (3.4.1) lib/devise/models/authenticatable.rb:178:in `send_devise_notification'
devise (3.4.1) lib/devise/models/recoverable.rb:99:in `send_reset_password_instructions_notification'
devise (3.4.1) lib/devise/models/recoverable.rb:49:in `send_reset_password_instructions'
devise (3.4.1) lib/devise/models/recoverable.rb:116:in `send_reset_password_instructions'
devise (3.4.1) app/controllers/devise/passwords_controller.rb:13:in `create'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
My devise.rb contains:
config.mailer_sender = "accounts@mydomain.com"
# Configure the class responsible to send e-mails.
config.mailer = 'Devise::Mailer'
My development.rb contains:
config.action_mailer.default_url_options = { :host => 'subdomain.mydomain.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp-relay.gmail.com", port: 465,
domain: "mydomain.com",
authentication: "plain",
enable_starttls_auto: false,
tls: true
}
I'm not sure what exactly is going wrong here. The email is generated just fine, and displayed on the server logs. However, it hits a 500 error when attempting to send it.
Anyone know where I should look to figure out what's going on?
回答1:
I had this error in Rails 6.0.0.rc1 with Devise 4.6.2 in development.
The fix was to add:
config.action_mailer.default_options = {
from: 'accounts@mydomain.com'
}
in application.rb (or in your environments/development.rb
)
回答2:
Improper SMTP settings seem to be the cause of many EOFError
s with Devise.
Use ssl: true
and remove any TLS options for port 465. If you'd rather use TLS, use port 587.
Source: Email client settings for Gmail
EDIT: Sorry, that suggestion was totally wrong. The tls and ssl options are actually just aliases of each other.
Note: According to this article, mail clients often use the terms “SSL” and “TLS” to refer not to the actual security protocols themselves, but rather to the practices of initiating a connection over a secure channel (so-called “SSL”) vs. starting off insecure, and then switching over to encrypted communication after establishing an initial handshake (so-called “TLS” but actually STARTTLS).
To clarify, you had it right to begin with:
- port 465 can go with either
ssl: true
ORtls: true
, and - port 587 goes with
enable_starttls_auto: true
(which is default, and thus not required).
So I don't know what was wrong with your configuration. Did you ever figure it out?
来源:https://stackoverflow.com/questions/28357235/eoferror-in-devisepasswordscontrollercreate