如何解决“连接到SMTP主机时出错:[Errno 10061]由于目标计算机主动拒绝连接而无法建立连接”? [英] How to solve "Error connecting to SMTP host: [Errno 10061] No connection could be made because the target machine actively refused it''?
问题描述
我正在创建一个应用程序,我需要在其中发送某些特定日志的邮件。
这是我的规则文件:
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_Info\ElastAlert\elastalert-master\smtp_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 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.
有任何解决方法的想法吗?
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]由于目标计算机主动拒绝连接而无法建立连接”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!