From 391f54917c289ba9aa64db53f02da69fd9314377 Mon Sep 17 00:00:00 2001 From: rgomez-eng Date: Sun, 19 Jun 2022 08:50:54 +0000 Subject: [PATCH] Fixed issue in 1.0.2 regarding SMTP TLS check. --- README.md | 1 + middlewares/mail.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d02b363..aaee36e 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ docker run -it --rm \ - `email-to` - mail address of the receiver of the mail. - `email-from` - mail address of the sender of the mail. - `mail-only-on-error` - only send a mail if the execution was not successful. +- `insecure-skip-verify` - ignore certificate checks on SMTP host. (+1.0.2 only!) - `save-folder` - directory in which the reports shall be written. - `save-only-on-error` - only save a report if the execution was not successful. diff --git a/middlewares/mail.go b/middlewares/mail.go index 3606d2a..32f353c 100644 --- a/middlewares/mail.go +++ b/middlewares/mail.go @@ -17,13 +17,13 @@ import ( // MailConfig configuration for the Mail middleware type MailConfig struct { - SMTPHost string `gcfg:"smtp-host" mapstructure:"smtp-host"` - SMTPPort int `gcfg:"smtp-port" mapstructure:"smtp-port"` - SMTPUser string `gcfg:"smtp-user" mapstructure:"smtp-user"` - SMTPPassword string `gcfg:"smtp-password" mapstructure:"smtp-password"` - EmailTo string `gcfg:"email-to" mapstructure:"email-to"` - EmailFrom string `gcfg:"email-from" mapstructure:"email-from"` - MailOnlyOnError bool `gcfg:"mail-only-on-error" mapstructure:"mail-only-on-error"` + SMTPHost string `gcfg:"smtp-host" mapstructure:"smtp-host"` + SMTPPort int `gcfg:"smtp-port" mapstructure:"smtp-port"` + SMTPUser string `gcfg:"smtp-user" mapstructure:"smtp-user"` + SMTPPassword string `gcfg:"smtp-password" mapstructure:"smtp-password"` + EmailTo string `gcfg:"email-to" mapstructure:"email-to"` + EmailFrom string `gcfg:"email-from" mapstructure:"email-from"` + MailOnlyOnError bool `gcfg:"mail-only-on-error" mapstructure:"mail-only-on-error"` InsecureSkipVerify bool `gcfg:"insecure-skip-verify" mapstructure:"insecure-skip-verify"` } @@ -92,15 +92,15 @@ func (m *Mail) sendMail(ctx *core.Context) error { })) d := gomail.NewPlainDialer(m.SMTPHost, m.SMTPPort, m.SMTPUser, m.SMTPPassword) - if err := d.DialAndSend(msg); err != nil { - return err - } - // InsecureSkipVerify is used to skip the certificate verification if m.InsecureSkipVerify == true { d.TLSConfig = &tls.Config{InsecureSkipVerify: true} } + if err := d.DialAndSend(msg); err != nil { + return err + } + return nil }