I'm new to ActionMailer, but I've also read the documentation on it. I am just not sure how Devise is handling it. I'm using Rails 5.1, yet I can't get the Devise mailer to work in development.
I get the following error when I try get the reset password email in development:
EOFError in Devise::PasswordsController#create
{"utf8"=>"✓",
"authenticity_token"=>"token info",
"user"=>{"email"=>"user@email.com"},
"commit"=>"Send me reset password instructions"}
In the server log:
Started POST "/users/password" for 127.0.0.1 at 2018-07-26 17:18:09 -0400
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"token", "user"=>{"email"=>"user@email.com"}, "commit"=>"Send me reset password instructions"}
User Load (1.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["email", "user@email.com"], ["LIMIT", 1]]
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["reset_password_token", "token"], ["LIMIT", 1]]
(0.3ms) BEGIN
SQL (0.7ms) UPDATE "users" SET "reset_password_token" = $1, "reset_password_sent_at" = $2, "updated_at" = $3 WHERE "users"."id" = $4 [["reset_password_token", "token"], ["reset_password_sent_at", "2018-07-26 21:18:10.075033"], ["updated_at", "2018-07-26 21:18:10.076032"], ["id", 2]]
(2.6ms) COMMIT
Rendering devise/mailer/reset_password_instructions.html.erb
Rendered devise/mailer/reset_password_instructions.html.erb (1.1ms)
Devise::Mailer#reset_password_instructions: processed outbound mail in 452.1ms
Sent mail to user@email.com (30027.6ms)
Date: Thu, 26 Jul 2018 17:18:11 -0400
To: user@email.com
Message-ID: <my system>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
... the view...
Completed 500 Internal Server Error in 31449ms (ActiveRecord: 5.6ms)
EOFError (end of file reached):
I've set up my config/environments/development.rb:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# Using MailCatcher server -- running @ 1080
config.action_mailer.smtp_settings = { address: "localhost", port: 1080 }
I have the MailCatcher server running. When I set 'raise_deliver_errors' = false, I get a flash saying the message is sent, but MailCatcher never receives anything.
I'm a little confused, every single thing I've researched says I only need to do this to make it work -- I don't want to play with the Devise Controllers if I don't have to.
Thanks!
What I did was just turn this line of code from
config.action_mailer.delivery_method = :smtp
into
config.action_mailer.delivery_method = :test
The views came up in the log, and when I configured Sendgrid on production the emails were sent properly.
Edit: this is in the development.rb
file