连接到SMTP主机时出错

连接到SMTP主机时出错

本文介绍了如何解决“连接到SMTP主机时出错:[Errno 10061]由于目标机器主动拒绝,无法建立连接"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,我需要在其中发送某些特定日志的邮件.这是我的规则文件:

I am creating an application where I need to send mail for some particular logs.Here is my rule file:

es_host: localhost
es_port: 9200
name: Log Level Test
type: frequency
index: testindexv4
num_events: 1
timeframe:
   hours: 4
filter:
 - term:
     log_level.keyword: "ERROR"
 - query:
     query_string:
       query: "log_level.keyword: ERROR"
alert:
- "email"
email:
- "<mailId>@gmail.com"

这里是 config.yaml

Here is the config.yaml

rules_folder: myrules
run_every:
  seconds: 2
buffer_time:
  seconds: 10
es_host: localhost
es_port: 9200
writeback_index: elastalert_status
alert_time_limit:
  days: 2

这里是 smpt_auth.yaml

Here is smpt_auth.yaml

alert:
 - email
email:
 - "<mailId>@gmail.com"
smtp_host: "smtp.gmail.com"
smtp_port: 587
smtp_ssl: true
from_addr: "<mailId>@gmail.com"
smtp_auth_file: 'D:ELK_InfoElastAlertelastalert-mastersmtp_auth_user.yaml'

这里是 smtp_auth_user.yaml

Here is smtp_auth_user.yaml

user: "<mailId>@gmail.com"
password: "<password>"

当我运行这个命令时:

python -m elastalert.elastalert --verbose --rule myrulesmyrule.yaml

我收到一个错误:

ERROR:root: Error while running alert email: Error connecting to SMTP host: [Errno 10061] No connection could be made because the target machine actively refused it.

请问您知道如何解决相同的问题吗?

Any idea on how to resolve the same, please?

推荐答案

请尝试检查以下链接:

https://stackoverflow.com/a/36532619/5062759

据我所知,完全不推荐使用 Gmail 发送电子邮件.它有一个限制,所以如果你是为生产服务(尤其是日志)做它,你会很快达到上限.我相信亚马逊的 SES 系统为开发人员提供积分,因此您可以修改它,或者如果您真的喜欢 Google,您可以使用:https://cloud.google.com/appengine/docs/standard/go/mail/.

From my understanding, it's not recommended AT ALL to use Gmail to send emails out. There's a limit to it, so if you're doing it for production services (especially logs) you'll hit the cap quickly. Amazon's SES system gives developer credits I believe so you can tinker with that or if you really like Google you could use: https://cloud.google.com/appengine/docs/standard/go/mail/.

这篇关于如何解决“连接到SMTP主机时出错:[Errno 10061]由于目标机器主动拒绝,无法建立连接"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:24