From f54fb81e8341a8a0111cd51c79444cc0c3963a43 Mon Sep 17 00:00:00 2001 From: Rayane Belkhir Date: Sun, 11 Aug 2024 14:07:27 +0200 Subject: [PATCH] feat: Allow for insecure servers --- mailme.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mailme.go b/mailme.go index 9dc91c9..e43074c 100644 --- a/mailme.go +++ b/mailme.go @@ -2,6 +2,7 @@ package mailme import ( "bytes" + "crypto/tls" "errors" "html/template" "io" @@ -31,6 +32,7 @@ type Mailer struct { Pass string BaseURL string LocalName string + Insecure bool FuncMap template.FuncMap cache *TemplateCache Logger logrus.FieldLogger @@ -72,6 +74,9 @@ func (m *Mailer) Mail(to, subjectTemplate, templateURL, defaultTemplate string, mail.SetBody("text/html", body) dial := gomail.NewDialer(m.Host, m.Port, m.User, m.Pass) + if m.Insecure { + dial.TLSConfig = &tls.Config{InsecureSkipVerify: true} + } if m.LocalName != "" { dial.LocalName = m.LocalName }