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 }