0

I'm experiencing some kind of regression error involving Devise and it's ability to send email to a user during the registration. I'm new to Rails and once I got Devise running, I kind of stopped experimenting with the registration portion. I recently upgraded my ruby version, wiped my development database, and when I tried to recreate some users I got this error:

Started POST "/users" for ::1 at 2016-10-02 09:32:34 -0400
Processing by DeviseInvitable::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"SFT9EQX83Aqg5jcdox1mLzlEGGRxUnvSngLgc08Hgysctg0BOI7Yrxv9UbWIjuS80Bf+hYHj0VA6B0LOMxTnLw==", "user"=>{"email"=>"user.name+test1@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
  User Load (154.7ms)  SELECT  `users`.* FROM `users` WHERE `users`.`email` = 'user.name+test1@gmail.com'  ORDER BY `users`.`id` ASC LIMIT 1
   (0.2ms)  BEGIN
  User Exists (3.3ms)  SELECT  1 AS one FROM `users` WHERE `users`.`email` = BINARY 'user.name+test1@gmail.com' LIMIT 1
  SQL (25.0ms)  INSERT INTO `users` (`email`, `encrypted_password`, `created_at`, `updated_at`, `confirmation_token`, `confirmation_sent_at`) VALUES ('user.name+test1@gmail.com', '$2a$10$20khSPmwRsCjxkiyjhiRE.BrYzV7Zu.6OY8rJnyLFB3Ju73PdLSLq', '2016-10-02 13:32:34', '2016-10-02 13:32:34', 'X2SBSZKmqTiV_As--ibW', '2016-10-02 13:32:34')
   (1.3ms)  COMMIT
  Rendered devise/mailer/confirmation_instructions.html.erb (1.0ms)

Devise::Mailer#confirmation_instructions: processed outbound mail in 173.1ms

Sent mail to user.name+test1@gmail.com (596.2ms)
Date: Sun, 02 Oct 2016 09:32:34 -0400
From: user.name@gmail.com
Reply-To: user.name@gmail.com
To: user.name+test1@gmail.com
Message-ID: <57f10c72dbcb5_c783ffd99fa77c0174cb@uname.ad.mdp.com.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome user.name+test1@gmail.com!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation?confirmation_token=X2SBSZKmqTiV_As--ibW">Confirm my account</a></p>

Completed 500 Internal Server Error in 1063ms (ActiveRecord: 184.5ms)

EOFError - end of file reached:
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:945:in `recv_response'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:931:in `block in getok'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:955:in `critical'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:929:in `getok'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:830:in `helo'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:604:in `do_helo'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:556:in `do_start'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
  mail (2.6.4) lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!'
  mail (2.6.4) lib/mail/message.rb:2149:in `do_delivery'
  mail (2.6.4) lib/mail/message.rb:237:in `block in deliver'
  actionmailer (4.2.3) lib/action_mailer/base.rb:543:in `block in deliver_mail'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument'
  actionmailer (4.2.3) lib/action_mailer/base.rb:541:in `deliver_mail'
  mail (2.6.4) lib/mail/message.rb:237:in `deliver'
  actionmailer (4.2.3) lib/action_mailer/message_delivery.rb:85:in `deliver_now'
  devise (4.2.0) lib/devise/models/authenticatable.rb:191:in `send_devise_notification'
  devise (4.2.0) lib/devise/models/confirmable.rb:117:in `send_confirmation_instructions'
  devise (4.2.0) lib/devise/models/confirmable.rb:179:in `send_on_create_confirmation_instructions'
  activesupport (4.2.3) lib/active_support/callbacks.rb:430:in `block in make_lambda'
  activesupport (4.2.3) lib/active_support/callbacks.rb:251:in `block in conditional'
  activesupport (4.2.3) lib/active_support/callbacks.rb:504:in `block in call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:504:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks'
  activerecord (4.2.3) lib/active_record/transactions.rb:314:in `committed!'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:89:in `commit_records'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:153:in `commit'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:175:in `commit_transaction'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:194:in `within_new_transaction'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
  activerecord (4.2.3) lib/active_record/transactions.rb:220:in `transaction'
  activerecord (4.2.3) lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
  activerecord (4.2.3) lib/active_record/transactions.rb:286:in `block in save'
  activerecord (4.2.3) lib/active_record/transactions.rb:301:in `rollback_active_record_state!'
  activerecord (4.2.3) lib/active_record/transactions.rb:285:in `save'
  devise (4.2.0) app/controllers/devise/registrations_controller.rb:17:in `create'
  actionpack (4.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.3) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.3) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.3) lib/active_support/callbacks.rb:115:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:553:in `block (2 levels) in compile'
  activesupport (4.2.3) lib/active_support/callbacks.rb:503:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks'
  actionpack (4.2.3) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.3) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.3) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.3) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.3) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:45:in `serve'
  actionpack (4.2.3) lib/action_dispatch/routing/mapper.rb:49:in `serve'
  actionpack (4.2.3) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.3) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:821:in `call'
  warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.6) lib/warden/manager.rb:34:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:38:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.3) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  activerecord (4.2.3) lib/active_record/migration.rb:377:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.3) lib/rails/engine.rb:518:in `call'
  railties (4.2.3) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

I am using gmail as my smtp server for dev & test environments. This was working fine - I was able to receive the emails at 'user.name+test1@gmail.com' (well, at the real version of that email addr) earlier.

I can't understand from the error message exactly what the problem is though. It looks like Devise was able to create the confirmation email:

Rendered devise/mailer/confirmation_instructions.html.erb (1.0ms)

Then it appears to say that the email was sent

Devise::Mailer#confirmation_instructions: processed outbound mail in 173.1ms

Sent mail to user.name+test1@gmail.com (596.2ms)

But something is reporting an EOF error. Presumably this is ruby's network adapter complaining that it expected more of the file being sent (the email data?), but ran out prematurely:

Completed 500 Internal Server Error in 1063ms (ActiveRecord: 184.5ms)

EOFError - end of file reached:
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'

But this is one of those things where I don't think I've changed any of the Devise configurations or views since Devise was working so I'd be surprised if the answer involved changing existing configs.

Has anyone experienced anything like this before? This post seems very similar (Ruby mailer is coming up with an EOFError) but didn't get any responses.

ALSO: I just saw that a record had been added to the User table for user.name+test1@gmail.com. There is a field there for the confirmation token and when I hit http://localhost:3000/users/confirmation?confirmation_token=[token from db] the user was confirmed and I was able to log in with them. So this error really must be localized to sending the confirmation email (which, again, never arrived in my inbox).

Edit: Here is my mailer config:

app/config/environments/development.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: Rails.application.secrets.email_provider_smtp_domain,
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: Rails.application.secrets.email_provider_username,
    password: Rails.application.secrets.email_provider_password
  }
  # ActionMailer Config
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  # Send email in development mode?
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default :charset => "utf-8"

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end
Community
  • 1
  • 1
doub1ejack
  • 10,627
  • 20
  • 66
  • 125
  • Paste your mail configurations, are you able to receive any other mail using the same configuration? – Chakreshwar Sharma Oct 04 '16 at 05:12
  • @ChakreshwarSharma: I added the config for my dev env. I don't have the app set up to send mail for many other reasons (this is kind of my first ruby app). As one would expect, the Forgot Password email that Devise sends also fails - seemingly with the same error. – doub1ejack Oct 04 '16 at 11:35
  • 1
    There might be a problem with your domain name, try the different one – Chakreshwar Sharma Oct 04 '16 at 13:08
  • Ah classic. My `config/secrets.yml` isn't tracked in git (naturally) and looks like it was overwritten and lost those entries for the email provider smtp/username/password at some point. Thanks @ChakreshwarSharma, that was the direction I needed. – doub1ejack Oct 04 '16 at 18:55
  • Hi, I'm struggling with the same issue, presumably also because my domain is incorrect. I am running my development environment from a server with no domain name, just an ip address. It's not clear to me what the "domain" value should be in the smpt_settings - I've tried the ip of my server, gmail.com, the domain of the gmail e-mail account that I'm using and nothing has worked so far. What is domain supposed to be set to? – codemonkey65 Jul 29 '17 at 07:47

0 Answers0