mhfs/devise-async

smtp settings not being forwarded

Closed this issue · 5 comments

Hi guys, my environment is:
rails-3.2.21
devise-async-0.10.1
sidekiq-3.4.2
devise-3.5.2

and my development.rb has the following lines:

AdBuilder::Application.configure do
    config.paperclip_defaults = { }
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = APPCONFIG.setup_mail
    config.action_mailer.default_url_options = { :host => APPCONFIG.host }
end

Mail.defaults do
   delivery_method :smtp, APPCONFIG.setup_mail
end

where
APPCONFIG.setup_mail = {"port"=>587, "address"=>"smtp.mailgun.org", "user_name"=>"username", "password"=>"password", "domain"=>"dom", "authentication"=>:plain, "enable_starttls_auto"=>true}

When I click 'forgot password' I get the following error:
2015-09-09T11:51:40.540Z 6949 TID-1b2a6k Devise::Async::Backend::Sidekiq JID-a860405bf58683ca0c52bf50 INFO: start
2015-09-09T11:51:40.690Z 6949 TID-1b2a6k Devise::Async::Backend::Sidekiq JID-a860405bf58683ca0c52bf50 INFO: fail: 0.15 sec
2015-09-09T11:51:40.697Z 6949 TID-1b2a6k WARN: {"class"=>"Devise::Async::Backend::Sidekiq", "args"=>["reset_password_instructions", "User", "1023", "hMq_QtTtFAe6yNoQzA-4", {}], "retry"=>true, "queue"=>"mailer", "jid"=>"a860405bf58683ca0c52bf50", "created_at"=>1441797909.8741653, "enqueued_at"=>1441799500.5298817, "error_message"=>"no implicit conversion of nil into Hash", "error_class"=>"TypeError", "failed_at"=>1441797929.8455174, "retry_count"=>6, "retried_at"=>1441799500.6890008}

2015-09-09T11:51:40.697Z 6949 TID-1b2a6k WARN: TypeError: no implicit conversion of nil into Hash
2015-09-09T11:51:40.697Z 6949 TID-1b2a6k WARN: /home/ingolfur/.rvm/gems/ruby-2.0.0-p645/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:90:in 'merge!'
/home/ingolfur/.rvm/gems/ruby-2.0.0-p645/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:90:in 'initialize'
/home/ingolfur/.rvm/gems/ruby-2.0.0-p645/gems/mail-2.5.4/lib/mail/message.rb:257:in 'new'
/home/ingolfur/.rvm/gems/ruby-2.0.0-p645/gems/mail-2.5.4/lib/mail/message.rb:257:in 'delivery_method'
/home/ingolfur/.rvm/gems/ruby-2.0.0-p645@/gems/actionmailer-3.2.21/lib/action_mailer/delivery_methods.rb:69:in 'wrap_delivery_behavior'
/home/ingolfur/.rvm/gems/ruby-2.0.0-p645@/gems/actionmailer-3.2.21/lib/action_mailer/delivery_methods.rb:83:in 'wrap_delivery_behavior!'

And when I byebug that method, it looks like the config.action_mailer.smtp_settings is not getting through (even though it's clearly defined with the right values for both sidekiq and the rails server). Any ideas how to solve / debug this?
Thanks!

@ingolfured Could you try using symbols instead of strings for the keys of APPCONFIG.setup_mail?

If I change
config.action_mailer.smtp_settings = APPCONFIG.setup_mail
to
config.action_mailer.smtp_settings = APPCONFIG.setup_mail.symbolize_keys
I get the same error. Do I need the values to be symbols as well? Very odd. Thanks!

And if I run byebug right before we send the email the output from Rails.application.config.action_mailer.smtp_settings is

{ :port=>587, :address=>"smtp.mailgun.org", :user_name=>"real_username", :password=>"cool_password", :domain=>"nicer_domain", :authentication=>:plain, :enable_starttls_auto=>true }

Never mind, there was an initializer that changed it back to strings.

@ingolfured Glad you solved your issue. :)