Search code examples
ruby-on-railsemailherokudevise

Rails 4: EOFError: end of file reached following any email in DEVELOPMENT only


I have rails app which uses devise ofr authentication and sidekiq for background email jobs. All of a sudden, in development only, I am getting the following error associated with an attempt to send an email from the app (e.g. devise forgotten password)

     EOFError: end of file reached

Strangely the app in production works (heroku set up using sendgrid). I haven't changed any of my development email settings....

  ActionMailer::Base.default :from => 'slfwalsh@gmail.com'

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

    config.action_mailer.default_url_options = { :host => 'localhost:3000' }

I can't find anything to address this online. Also I note that ALL my apps in development, using similar settings are throwing the same error. I tried a different email address and password (again gmail) and no luck....


Solution

  • For those who are stuck....this worked but I unclear why.

     config.action_mailer.raise_delivery_errors = true
    
     config.action_mailer.delivery_method = :smtp
    
     config.action_mailer.smtp_settings = {
      address: "smtp.gmail.com",
      port: 587,
      domain: "myprojectdomain.com",
      user_name: "xxxx@gmail.com",
      password: "xxxx",
      authentication: 'plain',
      enable_starttls_auto: true
     }
    
     config.action_mailer.default_url_options = { :host => 'localhost:3000' }