首页 > 解决方案 > Splunk sendemail 使用邮件服务器 smtp.gmail.com 失败 [Errno 99]

问题描述

来自/opt/splunk/var/log/splunk/python.log

2018-11-12 14:29:08,776 +0000 ERROR    sendemail:137 - Sending email. subject="Splunk Alert: Errors in develop", results_link="https://localhost:8000/app/search/@go?sid=rt_scheduler__admin__search__RMD58e26482826eced90_at_1542024571_26.426", recipients="[u'my_email@gmail.com']", server="localhost"
2018-11-12 14:29:08,776 +0000 ERROR    sendemail:458 - [Errno 99] Cannot assign requested address while sending mail to: my_email@gmail.com

我的/opt/splunk/etc/system/local/alert_actions.conf

 [email]
 auth_password = XXX
 auth_username = my_email@gmail.com
 hostname = localhost
 mailserver = smtp.gmail.com:465
 pdf.header_left = none
 pdf.header_right = none
 use_ssl = 1

我也试过smtp.gmail.com:587use_ssl = 0 use_tls = 1,在这两种情况下都有同样的错误。

但是,当尝试直接从搜索发送邮件时,它按预期工作:

... | sendemail to="my_email@gmail.com" format=raw sendresults=1 footer="Sent from Splunk." from="SplunkAlerts" subject="Splunk Alert" message="The following Splunk Alert has been fired:"

我缺少什么配置?errno 99 是 EADDRNOTAVAIL ,不清楚什么不可用,是server="localhost"错误日志中的吗?我应该在哪里设置它?

标签: smtpsplunkmail-server

解决方案


在您的配置中,您需要使用server=,而不是mailserver.

https://docs.splunk.com/Documentation/Splunk/7.2.0/SearchReference/Sendemail

请注意,Gmail 通常会很挑剔地尝试通过这种方式发送电子邮件,如果可能的话,我倾向于避免使用它。您是否配置了本地邮件服务器?


推荐阅读