fix(formmailer): set tls.Config.ServerName on StartTLS

This commit is contained in:
AJ ONeal 2026-04-20 22:38:49 -06:00
parent 5b16fc26df
commit a16aa6f73f
No known key found for this signature in database

View File

@ -36,6 +36,7 @@ package formmailer
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/tls"
"errors" "errors"
"fmt" "fmt"
"log" "log"
@ -384,7 +385,7 @@ func (fm *FormMailer) sendMail(ctx context.Context, msg []byte) error {
defer func() { _ = c.Close() }() defer func() { _ = c.Close() }()
if ok, _ := c.Extension("STARTTLS"); ok { if ok, _ := c.Extension("STARTTLS"); ok {
if err := c.StartTLS(nil); err != nil { if err := c.StartTLS(&tls.Config{ServerName: hostname}); err != nil {
return fmt.Errorf("starttls: %w", err) return fmt.Errorf("starttls: %w", err)
} }
} }