From 49aeaecf7ca231e6679d088d10342248dee6d21a Mon Sep 17 00:00:00 2001 From: Anuj Khandelwal Date: Thu, 14 Sep 2023 15:14:02 +0530 Subject: [PATCH] fix: pass ServerName in tls config to send mails in secure mode Golang's tls module expects a ServerName if InsecureSkipVerify is set to false. The ServerName is used to verify the hostname on the returned certificates. --- pkg/mailer/dialer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/mailer/dialer.go b/pkg/mailer/dialer.go index b36708068..6626a1319 100644 --- a/pkg/mailer/dialer.go +++ b/pkg/mailer/dialer.go @@ -35,6 +35,7 @@ func NewDialerImpl(SMTPHost string, SMTPPort int, SMTPUser string, SMTPPass stri d := mail.NewDialer(SMTPHost, SMTPPort, SMTPUser, SMTPPass) d.TLSConfig = &tls.Config{ InsecureSkipVerify: SMTPInsecure, + ServerName: SMTPHost, } d.StartTLSPolicy = mail.MandatoryStartTLS return &DialerImpl{