Set server name in TLS config (#13)

This commit is contained in:
Christoph Haas 2021-04-29 10:59:00 +02:00
parent 87964f8ec4
commit 9c8a1df01f

View File

@ -89,9 +89,9 @@ func SendEmailWithAttachments(cfg MailConfig, sender, replyTo, subject, body str
switch cfg.Encryption { switch cfg.Encryption {
case MailEncryptionTLS: case MailEncryptionTLS:
return e.SendWithTLS(hostname, auth, &tls.Config{InsecureSkipVerify: !cfg.CertValidation}) return e.SendWithTLS(hostname, auth, &tls.Config{ServerName: cfg.Host, InsecureSkipVerify: !cfg.CertValidation})
case MailEncryptionStartTLS: case MailEncryptionStartTLS:
return e.SendWithStartTLS(hostname, auth, &tls.Config{InsecureSkipVerify: !cfg.CertValidation}) return e.SendWithStartTLS(hostname, auth, &tls.Config{ServerName: cfg.Host, InsecureSkipVerify: !cfg.CertValidation})
default: // MailEncryptionNone default: // MailEncryptionNone
return e.Send(hostname, auth) return e.Send(hostname, auth)
} }