diff --git a/README.md b/README.md index 3dc3197f..c2ff37fe 100644 --- a/README.md +++ b/README.md @@ -476,6 +476,7 @@ endpoints: | `alerting.email.port` | Port the mail server is listening to (e.g. `587`) | Required `0` | | `alerting.email.to` | Email(s) to send the alerts to | Required `""` | | `alerting.email.default-alert` | Default alert configuration.
See [Setting a default alert](#setting-a-default-alert) | N/A | +| `alerting.email.client.insecure` | Whether to skip TLS verification | `false` | | `alerting.email.overrides` | List of overrides that may be prioritized over the default configuration | `[]` | | `alerting.email.overrides[].group` | Endpoint group for which the configuration will be overridden by this configuration | `""` | | `alerting.email.overrides[].to` | Email(s) to send the alerts to | `""` | @@ -489,6 +490,8 @@ alerting: host: "mail.example.com" port: 587 to: "recipient1@example.com,recipient2@example.com" + client: + insecure: false # You can also add group-specific to keys, which will # override the to key above for the specified groups overrides: diff --git a/alerting/provider/email/email.go b/alerting/provider/email/email.go index e16f8e37..2729d38e 100644 --- a/alerting/provider/email/email.go +++ b/alerting/provider/email/email.go @@ -1,11 +1,13 @@ package email import ( + "crypto/tls" "fmt" "math" "strings" "github.com/TwiN/gatus/v5/alerting/alert" + "github.com/TwiN/gatus/v5/client" "github.com/TwiN/gatus/v5/core" gomail "gopkg.in/mail.v2" ) @@ -19,6 +21,9 @@ type AlertProvider struct { Port int `yaml:"port"` To string `yaml:"to"` + // ClientConfig is the configuration of the client used to communicate with the provider's target + ClientConfig *client.Config `yaml:"client,omitempty"` + // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` @@ -62,6 +67,9 @@ func (provider *AlertProvider) Send(endpoint *core.Endpoint, alert *alert.Alert, m.SetHeader("Subject", subject) m.SetBody("text/plain", body) d := gomail.NewDialer(provider.Host, provider.Port, username, provider.Password) + if provider.ClientConfig != nil && provider.ClientConfig.Insecure { + d.TLSConfig = &tls.Config{InsecureSkipVerify: true} + } return d.DialAndSend(m) }