[英]Connection refused - connect(2) for “localhost” port 25 chef devops
I am working on chef(devops) where I have a helper library with the following code in it 我正在chef(devops)上工作,在其中有一个包含以下代码的帮助程序库
require 'net/smtp'
module HandlerSendEmail
class Helper
def send_email_on_run_failure(node_name)
message = "From: Chef <chef@chef.io>\n"
message << "To: Grant <xyz@test.com>\n"
message << "Subject: Chef run failed\n"
message << "Date: #{Time.now.rfc2822}\n\n"
message << "Chef run failed on #{node_name}\n"
Net::SMTP.start('localhost', 25) do |smtp|
smtp.send_message message, 'chef@chef.io', 'xyz@test.com'
end
end
end end 结束
But whhen I run the recipe I get 但是当我运行食谱时,我得到了
Chef Client failed. 0 resources updated in 02 seconds
[2017-10-30T05:19:38+00:00] ERROR: Connection refused - connect(2) for "localhost" port 25
[2017-10-30T05:19:38+00:00] ERROR: Connection refused - connect(2) for "localhost" port 25
I tried changing port to 90 and some other options I keep getting same error.There are some solution available on few posts on stackoverflow already but all of them are talking about some other .rb files which is not present on my dev environment. 我尝试将端口更改为90,并且其他一些选项仍然遇到相同的错误.stackoverflow上的一些帖子已经提供了一些解决方案,但所有这些都在谈论我的开发环境中不存在的其他.rb文件。
Connection refused - connect(2) Ruby on Rails Mail Setup Errno::ECONNREFUSED: Connection refused - connect(2) for action mailer 连接被拒绝 -connect (2)Ruby on Rails邮件设置 Errno :: ECONNREFUSED:连接被拒绝-动作邮件程序的connect(2)
You would need to have an actual SMTP server listening on localhost and I'm guessing you don't have one. 您可能需要在本地主机上侦听一个实际的SMTP服务器,而我猜您还没有一个。 Without more information it's hard to say though. 没有更多的信息,虽然很难说。 If you don't want run your own relay server, you can find instructions all over the internet for setting up outbound SMTP via GMail, Amazon SES, Sparkpost, Sendgrid, and may more. 如果您不想运行自己的中继服务器,则可以在Internet上找到有关通过GMail,Amazon SES,Sparkpost,Sendgrid等进行设置出站SMTP的说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.