Skip to content

Commit

Permalink
Merge pull request #23 from rgomez-eng/1.0.2.1
Browse files Browse the repository at this point in the history
Fixed issue in 1.0.2 regarding SMTP TLS check.
  • Loading branch information
maietta authored Jun 19, 2022
2 parents 9b6e215 + 391f549 commit 1cb1278
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 11 additions & 11 deletions middlewares/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1cb1278

Please sign in to comment.