From 9444bab05fb3cf9c80db3b7c2f03ced21262eb65 Mon Sep 17 00:00:00 2001 From: Cipher Vance Date: Sat, 15 Nov 2025 18:43:51 -0600 Subject: [PATCH] add support for better ssl/tls handling --- internal/email/email.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/email/email.go b/internal/email/email.go index 5305330..9f550f5 100644 --- a/internal/email/email.go +++ b/internal/email/email.go @@ -50,14 +50,23 @@ func SendUpdate(subject, body string) (string, error) { func send(subject, body, recipient string) bool { cfg := config.Current - client, err := mail.NewClient( - cfg.SMTPServer, + var opts []mail.ClientOption + opts = append(opts, mail.WithPort(cfg.SMTPPort), mail.WithSMTPAuth(mail.SMTPAuthPlain), mail.WithUsername(cfg.SMTPUser), mail.WithPassword(cfg.SMTPPassword), mail.WithTimeout(10*time.Second), ) + + // Use SSL for port 465, STARTTLS for others + if cfg.SMTPPort == 465 { + opts = append(opts, mail.WithSSL()) + } else { + opts = append(opts, mail.WithTLSPolicy(mail.TLSMandatory)) + } + + client, err := mail.NewClient(cfg.SMTPServer, opts...) if err != nil { log.Printf("Failed to create mail client: %v", err) return false