shunfei / cronsun

A Distributed, Fault-Tolerant Cron-Style Job System.
Apache License 2.0
2.91k stars 457 forks source link

报警发送邮件失败! WARN cronsun/noticer.go:96 close smtp server err: EOF #87

Open zhoud9012 opened 6 years ago

zhoud9012 commented 6 years ago

Please answer these questions before submitting your issue. Thanks! 在你提交 issue 前,请先回答以下问题,谢谢!

  1. What version of Go and cronsun version are you using? 你用的是哪个版本的 Go 和 哪个版本的 cronsun?

  2. What operating system and processor architecture are you using (go env)? 你用的是哪个操作系统,什么架构的?

  3. What did you do? If possible, provide a recipe for reproducing the error. A complete runnable program is good. 你做了什么,遇到了什么问题?尽可能描述清楚问题,最好把操作步骤写下来,按这些步骤操作后能重现你的问题。

  4. What did you expect to see? 你期望得到什么样的结果?

  5. What did you see instead? 现在你得到的结果是什么样的?

zhoud9012 commented 6 years ago

1.go version go1.8.3 linux/amd64 2.cronsun-v0.3.1-linux-amd64 3.开启报警 发送邮件失败 4.希望能成功发送报警邮件 5.我现在的结果是执行任务失败,发送邮件不成功。

为什么发送邮件返回,发送邮件不成功 2018-05-30T17:31:52.277+0800 WARN cronsun/noticer.go:96 close smtp server err: EOF

mail.json

{ "Enable": true, "To": ["xxxx@qq.com"], "#HttpAPI": "如有此字段,则按 http api 方式发送", "#Keepalive": "如果此时间段内没有邮件发送,则关闭 SMTP 连接,单位/秒", "Keepalive": 60, "#doc": "https://godoc.org/github.com/go-gomail/gomail#Dialer", "Host": "smtp.163.com", "Port": 465, "Username": "xxxx@163.com", "Password": "xxxxx", "SSL": true, "#LocalName": "LocalName is the hostname sent to the SMTP server with the HELO command. By default, 'localhost' is sent.", "LocalName": "" }

Doflatango commented 6 years ago

试下把 SSL 改为 false,或者把 Port 改成 25

nicksors commented 6 years ago

我也遇到了这个问题,请问@zhoud9012 解决这个问题了吗?

  1. 上诉ssl改为false方法已经测试,不行;
  2. 我本身使用的是Mac虚拟的CentOS7虚拟机系统。

希望能得到帮助,感谢亲们。

miraclesu commented 6 years ago

@nicksors 请问你用的是什么邮箱?

nicksors commented 6 years ago

@miraclesu 163邮箱

neilzhou commented 5 years ago

@nicksors , 问题解决了吗?我用最新的cronsun-v0.3.5-linux-amd64.zip, 在docker 环境下也报同样的错误,下面是详细信息: Mac 下的 docker image: centos:7.4.1708

conf/mail.json 配置, 因为mailtrap.io测试账号是用的2525 端口 { "Enable": true, "To": ["xxx@xxx.com"], "#HttpAPI": "如有此字段,则按 http api 方式发送", "#Keepalive": "如果此时间段内没有邮件发送,则关闭 SMTP 连接,单位/秒", "Keepalive": 60, "#doc": "https://godoc.org/github.com/go-gomail/gomail#Dialer", "Host": "smtp.mailtrap.io", "Port": 2525, "Username": "xxx", "Password": "xxx", "SSL": false, "#LocalName": "LocalName is the hostname sent to the SMTP server with the HELO command. By default, 'localhost' is sent.", "LocalName": "localhost" }

nicksors commented 5 years ago

@nicksors , 问题解决了吗?我用最新的cronsun-v0.3.5-linux-amd64.zip, 在docker 环境下也报同样的错误,下面是详细信息: Mac 下的 docker image: centos:7.4.1708

conf/mail.json 配置, 因为mailtrap.io测试账号是用的2525 端口 { "Enable": true, "To": ["xxx@xxx.com"], "#HttpAPI": "如有此字段,则按 http api 方式发送", "#Keepalive": "如果此时间段内没有邮件发送,则关闭 SMTP 连接,单位/秒", "Keepalive": 60, "#doc": "https://godoc.org/github.com/go-gomail/gomail#Dialer", "Host": "smtp.mailtrap.io", "Port": 2525, "Username": "xxx", "Password": "xxx", "SSL": false, "#LocalName": "LocalName is the hostname sent to the SMTP server with the HELO command. By default, 'localhost' is sent.", "LocalName": "localhost" }

并没有解决,后面没有继续研究了。

neilzhou commented 5 years ago

不好意思,我这个问题是因为没有在任务编辑里开启 “报警”的选项,开启后,发现有报错: exit status 1 To:[xxx@xxx.com]}] err: gomail: could not send email 1: gomail: invalid address "bbxxxfe": mail: no angle-addr

"bbxxxfe" 是我在conf/mail.json 配置的 "Username" 的值, 请问下是我哪里的配置有问题吗?

neilzhou commented 5 years ago

看起来是 cronsun/blob/master/noticer.go 文件 line 86行这里配置的是 Username 的问题,建议在conf/mail.json 增加一个FromEmail, 然后这里使用m.cf.FromEmail sm.SetHeader("From", m.cf.Username)

214031230 commented 5 years ago

问题解决了吗?