0

I've recently set up the devise gem for authentication and all is working well excluding the forgot my password function. My smtp is currently pointed towards a yahoo email address. Yet, I get a EOF end of file extension error. In development it delivers message just fine ,but to no avail in production. Also, I initialized the ENV variables for username and password with Heroku Config:set .Addtionally, I tried port 587. Any help would be much appreciated! I'm fairly new to rails and searched for similar log issues, but most varied significantly in similarity to this issue. Thank you!

config.action_mailer.perform_caching = false

  config.action_mailer.default_url_options = {:host => 'https:app.herokuapp.com' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true




  ActionMailer::Base.smtp_settings = {
    :user_name => ENV['example@yahoo.com'],
    :password => ENV['examplepass'],
    :domain => 'https://example.herokuapp.com/',
    :address => 'smtp.mail.yahoo.com',
    :port =>465,
    :authentication => "plain",
    :enable_starttls_auto => true,

  }

2 Answers2

0

My first think:

I think your file have non visible characters, try to clean your file. https://alvinalexander.com/blog/post/linux-unix/how-remove-non-printable-ascii-characters-file-unix

Erase the file and create a new one an rewrite the config, avoid the copy paste. maybe works if you do a copy paste without format to note bloc, word something like that and then copy that back to your file.

Also read more What is an EOFError in Ruby file I/O? https://airbrake.io/blog/ruby-exception-handling/eof-error

Continue searching i found this

EOFError in Devise::PasswordsController#create

Devise mailer EOF error a user comment this

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

Another one Rails EOFError (end of file reached) when saving a devise user

0

The resolution to my issue was two fold. I didn't have the heroku config vars properly set up and initialized.My .gitignore file didn't have the exclusions as well to prevent uploading to repository. In conclusion, I added the figaro gem, bundle exec install figaro , and it created the application.yml needed to store that actual user/pass information. https://railsapps.github.io/rails-environment-variables.html ----> quite useful in explaining the options for setting the vars.



  :user_name => ENV['SENDGRID_USERNAME'],
  :password => ENV['SENDGRID_PASSWORD'],
  :domain => 'heroku.com',
  :address => 'smtp.sendgrid.net',
  :port =>587,
  :authentication => :plain,
  :enable_starttls_auto => true,

Also in the above code , I didn't have domain specified to heroku.com but my application domain on Heroku. For production.rb you do need the default url set to your applications name. If you kept the default url "heroku.com" in production.rb it would 404 error when the emailed link was clicked on.

config.action_mailer.default_url_options = {:host => 'https://exampleapp.herokuapp.com/' }

Thanks for the help! I also hope this can be of help to other new rails devs.