Ruby on rails Cloudcontrol Rails 3邮件
问题:Ruby on rails Cloudcontrol Rails 3邮件,ruby-on-rails,email,cloudcontrol,Ruby On Rails,Email,Cloudcontrol,问题: Errno::ECONNREFUSED(连接被拒绝-为“localhost”端口25连接(2): 在cloudcontrol服务器上 环境smtp设置: config.action_mailer.smtp_settings = { address: "smtp.mandrillapp.com", port: 587, enable_starttls_auto: true, user_name: ENV["MANDRILL_USER"], p
Errno::ECONNREFUSED(连接被拒绝-为“localhost”端口25连接(2):
在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\u mailer.smtp\u settings
在服务器上,接收此信息,它是正确的:
{:address=>“smtp.mandrillapp.com”,:port=>587,:enable\u starttls\u auto=>true,:user\u name=>“correct\u user”,:password=>“correct\u password”,:authentication=>“login”}
但由于上述问题,我们仍然无法发送电子邮件。Mailer以某种方式跳过此设置并使用: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">
编辑:
以下是我在服务器上找到的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
问题出现在staging.rb中:
config.after_initialize do
#adding smtp settings in this block was invisible (or too late) for staging.rb
end
它可能会帮助不熟悉rails初始化过程的人。我不是真的:)对于其他遇到这个问题的人来说,塞尔吉的诊断是正确的,但有一个解决办法。在config.action\u mailer上设置smtp\u设置后,将其复制到ActionMailer::Base.smtp\u设置:
ActionMailer::Base.smtp_settings = config.action_mailer.smtp_settings
能否提供完整的生产配置文件-config/environments/production.rb?@mkorszun,谢谢。我已经添加了配置文件。能否请您选择?部署到cloudControl时是否可能使用非生产配置?配置文件看起来正常-是否在Procfile中显式导出RAILS_ENV?@mkorszun,这是暂存配置(生产配置相同)文件,默认情况下cloudControl RAILS_ENV设置为
RAILS_ENV:staging
。如果我更改了配置文件中的任何其他内容,并根据这些更改重新部署运行的临时应用程序。应用程序在服务器上运行时唯一跳过的是smtp_设置。不要忘记将RACK_ENV
设置为staging
。
ActionMailer::Base.smtp_settings = config.action_mailer.smtp_settings