fix: alarm email forward
This commit is contained in:
@@ -115,6 +115,8 @@ alarm:
|
||||
port: 25
|
||||
user: smtpuser
|
||||
password: xxxxxx
|
||||
# TLS skip verify: true/false
|
||||
tlsSkipVerify: true
|
||||
sms:
|
||||
apiURL: http://smsc.xxx.com
|
||||
accessKeyID: xxx
|
||||
@@ -127,6 +129,7 @@ alarm:
|
||||
# token: true/false to check accessToken
|
||||
# expires for session, unit: second
|
||||
# Support single/multiple session of user
|
||||
#
|
||||
auth:
|
||||
crypt: bcrypt
|
||||
token: true
|
||||
|
||||
@@ -17,15 +17,27 @@ func AlarmEmailForward(alarmData *Alarm) error {
|
||||
log.Info("AlarmEmailForward processing... ")
|
||||
|
||||
message := fmt.Sprintf(`
|
||||
<p>Alarm information</p>
|
||||
<p style="text-indent:3em">Sequence: %d</p>
|
||||
<p>Alarm information</p>
|
||||
<p style="text-indent:2.5em">Sequence: %d</p>
|
||||
<p style="text-indent:3em">NE name: %s</p>
|
||||
<p style="text-indent:4em">Title: %s</p>
|
||||
<p style="text-indent:5em">Title: %s</p>
|
||||
<p style="text-indent:3em">Severity: %s</p>
|
||||
<p style="text-indent:2em">Event Time: %s</p>
|
||||
<p style="text-indent:2em">The messsage is forwarded from OMC automatically, don't reply!</p>
|
||||
<p style="text-indent:2em">Automatic send by OMC, don't reply!</p>
|
||||
`, alarmData.AlarmSeq, alarmData.NeName, alarmData.AlarmTitle, alarmData.OrigSeverity, alarmData.EventTime)
|
||||
|
||||
// message := fmt.Sprintf(`
|
||||
// Alarm information
|
||||
|
||||
// Sequence: %d
|
||||
// NE name: %s
|
||||
// Title: %s
|
||||
// Severity: %s
|
||||
// Event Time: %s
|
||||
|
||||
// Automatic send by OMC, don't reply!
|
||||
// `, alarmData.AlarmSeq, alarmData.NeName, alarmData.AlarmTitle, alarmData.OrigSeverity, alarmData.EventTime)
|
||||
|
||||
// QQ 邮箱:
|
||||
// SMTP 服务器地址:smtp.qq.com(SSL协议端口:465/994 | 非SSL协议端口:25)
|
||||
// 163 邮箱:
|
||||
@@ -78,7 +90,7 @@ func AlarmEmailForward(alarmData *Alarm) error {
|
||||
m.SetBody("text/html", message)
|
||||
|
||||
// text/plain的意思是将文件设置为纯文本的形式,浏览器在获取到这种文件时并不会对其进行处理
|
||||
// m.SetBody("text/plain", "纯文本")
|
||||
//m.SetBody("text/plain", message)
|
||||
// m.Attach("test.sh") // 附件文件,可以是文件,照片,视频等等
|
||||
// m.Attach("lolcatVideo.mp4") // 视频
|
||||
// m.Attach("lolcat.jpg") // 照片
|
||||
@@ -91,6 +103,10 @@ func AlarmEmailForward(alarmData *Alarm) error {
|
||||
)
|
||||
// 关闭SSL协议认证
|
||||
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
if !config.GetYamlConfig().Alarm.Email.TlsSkipVerify {
|
||||
// 打开SSL协议认证
|
||||
d.TLSConfig = &tls.Config{InsecureSkipVerify: false}
|
||||
}
|
||||
|
||||
if err := d.DialAndSend(m); err != nil {
|
||||
operResult := fmt.Sprintf("Failed to DialAndSend:%v", err)
|
||||
|
||||
@@ -82,10 +82,11 @@ type YamlConfig struct {
|
||||
Alarm struct {
|
||||
ForwardAlarm bool `yaml:"forwardAlarm"`
|
||||
Email struct {
|
||||
Smtp string `yaml:"smtp"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Smtp string `yaml:"smtp"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
TlsSkipVerify bool `yaml:"tlsSkipVerify"`
|
||||
} `json:"email"`
|
||||
SMS struct {
|
||||
ApiURL string `yaml:"apiURL"`
|
||||
|
||||
@@ -115,6 +115,8 @@ alarm:
|
||||
port: 25
|
||||
user: smtpext@agrandtech.com
|
||||
password: "1000smtp@omc!"
|
||||
# TLS skip verify: true/false
|
||||
tlsSkipVerify: true
|
||||
sms:
|
||||
apiURL: http://smsc.xxx.com.cn/
|
||||
accessKeyID: xxxx
|
||||
|
||||
Reference in New Issue
Block a user