0

問題: Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25): cloudcontrol サーバー上。

環境 SMTP 設定:

   config.action_mailer.smtp_settings = {
    address: "smtp.mandrillapp.com",
    port: 587,
    enable_starttls_auto: true, 
    user_name: ENV["MANDRILL_USER"],
    password: ENV["MANDRILL_PASSWORD"],
    authentication: 'login',
    domain: 'domain.example'
}

サーバー上で確認する Project::Application.config.action_mailer.smtp_settingsと、これが正しく表示されます。

{:address=>"smtp.mandrillapp.com", :port=>587, :enable_starttls_auto=>true, :user_name=>"correct_user", :password=>"correct_password", :authentication=>"login"}

しかし、上記の問題により、猫はまだメールを送信しません。メーラーはどういうわけかこの設定をスキップして、:address=>"localhost", :port=>25 を使用します。サーバー コンソールでアドレスとポートを指定して Net::SMTP を直接使用すると、メールが適切に送信されます。

Net::SMTP.start('smtp.mandrillapp.com', 587, 'some_domain', ENV["MANDRILL_USER"], ENV["MANDRILL_PASSWORD"], :login) do |smtp|
 smtp.send_message msgstr, 
 'user@mail.com',
 'user1@mail.com'
end

=> #<Net::SMTP::Response:0x007f1a6e763998 @status="250", @string="250 2.0.0 Ok: queued as B768D480191\n">

cloudcontrol で smtp 設定を設定するのを手伝ってくれる人はいますか? または、cloudcontrolプラットフォームについて何か見逃したことがありますか?

実際にはステージングサーバーです...

Project::Application.configure do

 config.cache_classes = true
 config.action_controller.default_url_options = {:host => "staging_server_host"}
 config.action_mailer.default_url_options = {:host => 'staging_server_host'}
 config.consider_all_requests_local = false

 config.action_controller.perform_caching = true
 config.serve_static_assets = false
 config.action_mailer.delivery_method = :smtp

 config.action_mailer.perform_deliveries = true
 config.assets.compress = true
 config.assets.compile = true

 config.assets.digest = true
 config.log_level = :debug
 config.action_controller.asset_host = "staging_server_host"

 config.action_mailer.raise_delivery_errors = true
 config.i18n.fallbacks = true
 config.active_support.deprecation = :notify

 config.after_initialize do
   config.action_mailer.smtp_settings = {
       address: "smtp.mandrillapp.com",
       port: 587, # ports 587 and 2525 are also supported with STARTTLS
       enable_starttls_auto: true, # detects and uses STARTTLS
       user_name: ENV["MANDRILL_USER"],
       password: ENV["MANDRILL_PASSWORD"], # SMTP password is any valid mandrill API key
       authentication: 'login', # Mandrill supports 'plain' or 'login'
       domain: 'cloudcontrolapp.com', # your domain to identify your server when connecting
   }
 end
end

編集済み: サーバーで見つけた Procfile は次のとおりです。

web: bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT
rake: bundle exec rake
worker: bundle exec rake jobs:work
console: bundle exec rails console
4

2 に答える 2

1

問題は staging.rb にありました:

config.after_initialize do
  #adding smtp settings in this block was invisible (or too late) for staging.rb
end

おそらく、レールの初期化プロセスに慣れていない人に役立つでしょう。私はそうではありません:)

于 2014-11-20T10:07:31.880 に答える
0

この問題に遭遇した他の人にとっては、Sergii の診断は正しいですが、回避策があります。config.action_mailer で smtp_settings を設定したら、それらを ActionMailer::Base.smtp_settings にコピーします。

ActionMailer::Base.smtp_settings = config.action_mailer.smtp_settings
于 2014-12-30T01:31:07.480 に答える