首页 > 解决方案 > Ruby on rails 应用程序不发送电子邮件

问题描述

我是新来的,在 Linux 方面非常有经验,在 Ruby 方面非常新。

我已经完全重新安装了一个旧的损坏的 Debian 7.8 服务器,它运行带有 PostgreSql db 的 Ruby On Rails 应用程序。

要运行新安装,我必须更改Gemfile以适应新的 ruby​​ 包版本。

新服务器正在运行 Debian GNU/Linux 9 (stretch),并且所有 ruby​​ 软件包都已从 debian 软件包安装以供系统范围使用。

现在它运行 ruby​​ 2.3.3,非常好。我第一次安装这样的服务器,我为此感到非常自豪。

但是无法从应用程序发送电子邮件。我可以使用 Linux 邮件命令从该服务器发送电子邮件,sendmail 守护程序正在运行,但 ruby​​ 应用程序无法发送电子邮件。

我最初收到错误,然后我更改了config/environments/production.rb中的邮件参数,如下所示,显然没有更多错误:

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_files = false
  config.assets.js_compressor = :uglifier
  config.assets.compile = true
  config.assets.digest = true
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.action_mailer.smtp_settings = {
    address: "mailserver.com",
    port: 465,
    domain: Rails.application.secrets.domain_name,
    authentication: :plain,
    enable_starttls_auto: true,
    user_name: Rails.application.secrets.email_provider_username,
    password: Rails.application.secrets.email_provider_password
  }
  config.action_mailer.default_url_options = { 
    :host => Rails.application.secrets.domain_name,
    :protocol => 'https' 
  }
  config.action_mailer.default_options = {
    from: "Centre Sesame <contact@mailserver.com>",
    reply_to: "contact@mailserver.com"
  }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
end

我在生产日志中搜索了一些发送电子邮件的请求:

I, [2018-07-02T19:16:08.110776 #17945]  INFO -- : Started GET "/users/password/new" for xx.yyy.zzz.15 at 2018-07-02 19:16:08 +0200
I, [2018-07-02T19:16:08.114272 #17945]  INFO -- : Processing by Devise::PasswordsController#new as HTML
I, [2018-07-02T19:16:08.123870 #17945]  INFO -- :   Rendered devise/passwords/new.html.erb within layouts/application (2.1ms)
I, [2018-07-02T19:16:08.124890 #17945]  INFO -- :   Rendered layouts/_topbar.html.erb (0.2ms)
I, [2018-07-02T19:16:08.125064 #17945]  INFO -- :   Rendered layouts/_messages.html.erb (0.1ms)
I, [2018-07-02T19:16:08.125255 #17945]  INFO -- : Completed 200 OK in 11ms (Views: 9.7ms | ActiveRecord: 0.0ms)
I, [2018-07-02T19:16:11.617686 #17945]  INFO -- : Started POST "/users/password" for xx.yyy.zzz.15 at 2018-07-02 19:16:11 +0200
I, [2018-07-02T19:16:11.619438 #17945]  INFO -- : Processing by Devise::PasswordsController#create as HTML
I, [2018-07-02T19:16:11.619535 #17945]  INFO -- :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"yI1T7u39N/xxxxxxxxxxxxxxxl8EqvuXupFiijmMtMDHimdtsGMIKkF9HzP17PMsEflWdFn/g==", "user"=>{"email"=>"name@yahoo.fr"}, "commit"=>"Valider"}
I, [2018-07-02T19:16:11.630951 #17945]  INFO -- :   Rendered devise/passwords/new.html.erb within layouts/application (3.8ms)
I, [2018-07-02T19:16:11.632109 #17945]  INFO -- :   Rendered layouts/_topbar.html.erb (0.2ms)
I, [2018-07-02T19:16:11.632296 #17945]  INFO -- :   Rendered layouts/_messages.html.erb (0.1ms)
I, [2018-07-02T19:16:11.632480 #17945]  INFO -- : Completed 200 OK in 13ms (Views: 6.2ms | ActiveRecord: 0.5ms)

我应该在哪里查找更多详细信息?我错过了什么?

显然一切都是正确的,没有错误。

我应该在哪里找到错误。

当然,我已经在电子邮件服务器上检查了电子邮件帐户凭据。

你能帮忙吗?

非常感谢。

帕特里克

标签: ruby-on-railsrubyemailmailer

解决方案


推荐阅读