python - 如何解决 "Error connecting to SMTP host: [Errno 10061] No connection could be made because the target machine actively refused it''?

标签 python elasticsearch elastalert

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

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

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

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_Info\ElastAlert\elastalert-master\smtp_auth_user.yaml'

这里是 smtp_auth_user.yaml

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

当我运行这个命令时:

python -m elastalert.elastalert --verbose --rule myrules\myrule.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.

请问有什么解决办法吗?

最佳答案

请尝试检查以下链接:

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

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

关于python - 如何解决 "Error connecting to SMTP host: [Errno 10061] No connection could be made because the target machine actively refused it''?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52386437/

相关文章:

python - 属性错误: 'module' object has no attribute 'connect'

python - 有没有办法知道 Tkinter optionmenu 下拉菜单是否处于事件状态?

python - 如何告诉ElasticSearch多重匹配查询我希望数字字段(以字符串形式存储)返回与数字字符串匹配的内容?

以 "@"为前缀的 ElasticSearch 字段

python - Elastalert 无法从模块 stomp 中导入单调时间

python - Tensorflow - S3 对象不存在

python - 没有使用 smtplib 发送电子邮件 - python

elasticsearch - 将stdout和stderr运送到Logstash

email - Elastalert使用字段值作为电子邮件警报中的地址