简体   繁体   English

设计升级到Rails 5后不发送电子邮件

[英]Devise not sending emails after upgrading to Rails 5

I am having issues to get Devise working after upgrading from Rails 4.2 to 5. Running on Rails 4 everything worked like a charm, but post update no notifications were sent in development and production. 在从Rails 4.2升级到5之后,我遇到了让Devise工作的问题。在Rails上运行4一切都像魅力一样,但是更新后没有通知在开发和生产中发送。 Initially, I left all the settings as they were - once aware of the problem I made a few changes, and this is what I have at the moment (Please note I re-run the devise installer at some point, which replaced the initializer/devise.rb) 最初,我保留了所有设置 - 一旦发现问题我做了一些更改,这就是我现在所拥有的(请注意我在某个时候重新运行设备安装程序,它取代了初始化程序/ devise.rb)

development.rb development.rb

Rails.application.configure do
  ..
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default :charset => "utf-8"
  config.action_mailer.perform_caching = false
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
end

initializers/devise.rb 初始化/ devise.rb

  # ==> Mailer Configuration
  # Configure the e-mail address which will be shown in Devise::Mailer,
  # note that it will be overwritten if you use your own mailer class
  # with default "from" parameter.
  config.mailer_sender = 'noreply@mydomain.com'

  # Configure the class responsible to send e-mails.
  config.mailer = 'Devise::Mailer'

  # Configure the parent class responsible to send e-mails.
  config.parent_mailer = 'ActionMailer::Base'

I also followed the instructions issued by devise (ie extending routes, etc.) 我也按照设计发布的指示(即扩展路线等)

The only specialty that had been added is that I am using Active Job to deliver ActionMailer messages and therefore added this to my User Model to override send_devise_notification : 已经补充说,唯一的特长就是我使用活动作业提供的ActionMailer消息,因此将此添加到我的用户模型覆盖send_devise_notification:

def send_devise_notification(notification, *args)
  devise_mailer.send(notification, self, *args).deliver_later
end

Looking at the console output, it does not suggest in any way that the devise/mailer/confirmation_instructions.html.haml is ever being rendered. 纵观控制台输出,它不以任何方式使色器件/邮件/ confirmation_instructions.html.haml是不断渲染建议。

DEBUG: Chewy strategies stack: [2] -> atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Started POST "/en/users" for ::1 at 2016-10-13 14:05:41 +0200
DEBUG: Chewy strategies stack: [2] <- atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Processing by RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"CZ0wqg4a/atdIYfZ/QOj3b/UsTl0oqkBrcZjS9ZF6vaJi4JSD3nO2EGcCVVaM+5QYTM7+Iw40q+zkxAWSDVj9A==", "user"=>{"country"=>"AF", "email"=>"right@right.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "tcagree"=>"1"}, "g-recaptcha-response"=>"", "commit"=>"Sign up for free!", "locale"=>"en"}
   (0.3ms)  BEGIN
  User Exists (0.9ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "right@right.com"], ["LIMIT", 1]]
  SQL (13.4ms)  INSERT INTO "users" ("email", "encrypted_password", "confirmation_token", "confirmation_sent_at", "created_at", "updated_at", "roles_mask", "country") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["email", "right@right.com"], ["encrypted_password", "$2a$11$BzxtTw3PwaH06K6tpNlXHOtv.7sxgmVGhZyouIMzDfXP.cxnF2YGy"], ["confirmation_token", "Q-k8t3k-AmAoQoxggdcW"], ["confirmation_sent_at", 2016-10-13 12:05:42 UTC], ["created_at", 2016-10-13 12:05:42 UTC], ["updated_at", 2016-10-13 12:05:42 UTC], ["roles_mask", 64], ["country", "AF"]]
  SQL (0.7ms)  UPDATE "users" SET "id" = $1, "encrypted_password" = $2, "confirmation_token" = $3, "confirmation_sent_at" = $4, "created_at" = $5, "updated_at" = $6, "username" = $7, "roles_mask" = $8, "unconfirmed_email" = $9, "country" = $10 WHERE "users"."id" = $11  [["id", 16], ["encrypted_password", "$2a$11$BzxtTw3PwaH06K6tpNlXHOtv.7sxgmVGhZyouIMzDfXP.cxnF2YGy"], ["confirmation_token", "G3VSGdh-Q2C3sg1mxevB"], ["confirmation_sent_at", 2016-10-13 12:05:42 UTC], ["created_at", 2016-10-13 12:05:42 UTC], ["updated_at", 2016-10-13 12:05:42 UTC], ["username", "user-3aff9416"], ["roles_mask", 64], ["unconfirmed_email", "right@right.com"], ["country", "AF"], ["id", 16]]
   (3.5ms)  COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 377ms (ActiveRecord: 18.8ms)


DEBUG: Chewy strategies stack: [2] -> atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Started GET "/" for ::1 at 2016-10-13 14:05:42 +0200
DEBUG: Chewy strategies stack: [2] <- atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Processing by StaticPagesController#redirect as HTML
Redirected to http://localhost:3000/en
Filter chain halted as :set_locale rendered or redirected
Completed 302 Found in 14ms (ActiveRecord: 0.0ms)


DEBUG: Chewy strategies stack: [2] -> atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Started GET "/en" for ::1 at 2016-10-13 14:05:42 +0200
DEBUG: Chewy strategies stack: [2] <- atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Processing by StaticPagesController#welcome as HTML
  Parameters: {"locale"=>"en"}
  Rendering static_pages/welcome.html.haml within layouts/home
  Rendered shared/_fb_image.html.haml (2.3ms)
  Rendered static_pages/welcome.html.haml within layouts/home (13.4ms)
  Rendered layouts/navs/_standard.html.haml (6.8ms)
  Rendered layouts/_flashes.html.haml (3.0ms)
  Rendered layouts/general/_shim.html.erb (0.9ms)
  Rendered layouts/scripts/_google_analytics.html.haml (1.8ms)
  Rendered layouts/_navbar.html.haml (2.6ms)
  Rendered cookies_eu/_consent_banner.html.haml (1.8ms)
  Rendered layouts/_footer.html.haml (2.8ms)
  Rendered layouts/_base.html.haml (557.4ms)
Completed 200 OK in 606ms (Views: 601.2ms | ActiveRecord: 0.0ms)


DEBUG: Chewy strategies stack: [2] -> atomic @ /Users/georg/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17

Any input would be highly appreciated 任何意见都将受到高度赞赏

Forgot to mention current versions I am running on: Devise - 4.2.0, Ruby - ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15], Rails - Rails 5.0.0 忘了提到我正在运行的当前版本:Devise - 4.2.0,Ruby - ruby​​ 2.2.4p230(2015-12-16 revision 53155)[x86_64-darwin15],Rails - Rails 5.0.0

Since I was not able to get it working - even after removing all customizations and installing devise from scratch I decided to write my mailers that get fired on sign up, password reset, and invitations - it was more time effective. 由于我无法使其正常工作 - 即使在删除所有自定义项并从头开始安装设计后,我决定编写我的邮件,这些邮件会因注册,密码重置和邀请而被解雇 - 这是更有效的时间。 If anyone ever hits this problem and figures out a more simple and standardized solution - please post! 如果有人遇到这个问题,并找出一个更简单和标准化的解决方案 - 请发布!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM