From 062279e5d0a3bdf8a2c38a8d66be165c82161828 Mon Sep 17 00:00:00 2001 From: teddy Date: Mon, 21 Apr 2025 14:23:15 +0700 Subject: [PATCH] update --- helper/helper.go | 8 +++++++- route/route.go | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/helper/helper.go b/helper/helper.go index 9f5a850..8c14bc9 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -80,10 +80,16 @@ func SendEmail(to []string, cc []string, name, subject, message, htmlString stri body := htmlString messages := []byte(sender + subjectt + mime + body) + for _, v := range cc { + if v != "" { + to = append(to, cc...) + } + } + auth := smtp.PlainAuth("", config.Mail().AuthEmail, config.Mail().AuthPassword, config.Mail().SMTPHost) smtpAddr := fmt.Sprintf("%s:%d", config.Mail().SMTPHost, config.Mail().SMTPPort) - err := smtp.SendMail(smtpAddr, auth, config.Mail().AuthEmail, append(to, cc...), messages) + err := smtp.SendMail(smtpAddr, auth, config.Mail().AuthEmail, to, messages) if err != nil { return err } diff --git a/route/route.go b/route/route.go index 2c1f212..d0e561a 100644 --- a/route/route.go +++ b/route/route.go @@ -227,6 +227,12 @@ func Route(db *gorm.DB) { sendTo := request.To + for _, v := range request.CC { + if v != "" { + sendTo = append(sendTo, request.CC...) + } + } + type Data struct { Message string }