Problem:
Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
on cloudcontrol server.
Environment smtp settings:
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'
}
When checking the
Project::Application.config.action_mailer.smtp_settings
on server, receive this and it is correct:
{:address=>"smtp.mandrillapp.com", :port=>587, :enable_starttls_auto=>true, :user_name=>"correct_user", :password=>"correct_password", :authentication=>"login"}
But still cat't send email becouse of problem described above. Mailer somehow skips this settings and uses :address=>"localhost", :port=>25 If I use Net::SMTP directly with indicating the address and port on the server console it sends mail properly:
Net::SMTP.start('smtp.mandrillapp.com', 587, 'some_domain', ENV["MANDRILL_USER"], ENV["MANDRILL_PASSWORD"], :login) do |smtp|
smtp.send_message msgstr,
'[email protected]',
'[email protected]'
end
=> #<Net::SMTP::Response:0x007f1a6e763998 @status="250", @string="250 2.0.0 Ok: queued as B768D480191\n">
Can anyone help to set smtp settings on cloudcontrol? Or have I missed somethig about the cloudcontrol platform?
It is actually staging server...
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
EDITED: Here is Procfile I found on server:
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
The problem was here in staging.rb:
Possibly it will help someone who is not familiar with rails initializing process. I am not really:)