From f82f4f492bb2c1f5be2beb28b4a35f1a88ae197f Mon Sep 17 00:00:00 2001 From: ayush00git Date: Fri, 14 Aug 2026 14:11:17 +0530 Subject: [PATCH 1/2] fix(email): set new html bodies for emails --- services/email.go | 168 +++++++++++++++++++++++++--------------------- 1 file changed, 93 insertions(+), 75 deletions(-) diff --git a/services/email.go b/services/email.go index 29ebc77..1afa6d2 100644 --- a/services/email.go +++ b/services/email.go @@ -3,6 +3,7 @@ package services import ( "fmt" "log" + "time" "github.com/ayush00git/cms-web/helpers" "github.com/wneessen/go-mail" @@ -33,6 +34,71 @@ func SendMail(to, subject, body string) (error) { return c.DialAndSend(m) } +// buildEmailHTML builds the shared HTML email template used across all +// outgoing mails, so every mail shares the same look and feel. +func buildEmailHTML(heading, message, buttonText, buttonURL string) string { + return fmt.Sprintf(` + + + + + + %s + + + + + + + + +
+ + + + + + + + + + + + + + +
+

+ %s +

+

+ %s +

+ + + + + + +
+ + %s + +
+
+

+ © %d CMS. All rights reserved. +

+
+ + +
+ + + + `, heading, heading, message, buttonURL, buttonText, time.Now().Year()) +} + // SendVerificationMail sends email to the user who just signed up func SendVerificationMail(userId uint, email, role string) (error) { // generate the token @@ -46,26 +112,13 @@ func SendVerificationMail(userId uint, email, role string) (error) { verificationURL := fmt.Sprintf(`%s/account/verify?token=%s`, frontendURL, token) // send the email - mail := fmt.Sprintf(` - - - - - - - -

Verifying it's you.

-

Thanks for signing up! get started with cms.

-

- Get Started! -

- - - `, verificationURL) - + mail := buildEmailHTML( + "Verify your account", + "Thanks for signing up! Get started with CMS.", + "Verify Email Address", + verificationURL, + ) + err = SendMail(email, "Verification of your cms account", mail) if err != nil { return err @@ -84,24 +137,12 @@ func SendPasswordResetMail(userID uint, email, role string) error { resetURL := fmt.Sprintf(`%s/account/reset-password?user=%s`, frontendURL, token) // send the email - mail := fmt.Sprintf(` - - - - - - - -

Reset your password

-

- Reset! -

- - - `, resetURL) + mail := buildEmailHTML( + "Reset your password", + "We received a request to reset your password.", + "Reset Password", + resetURL, + ) err = SendMail(email, "Reset your cms account password", mail) if err != nil { @@ -112,25 +153,14 @@ func SendPasswordResetMail(userID uint, email, role string) error { } func SendPostMailToAdmins(email, postURL string) error { - mail := fmt.Sprintf(` - - - - - - - -

cms: updates on your recent complaint

-

- View Updates -

- - - `, postURL) -// sends the email + mail := buildEmailHTML( + "cms: updates on a recent complaint", + "There has been an update on a complaint.", + "View Updates", + postURL, + ) + + // sends the email err := SendMail(email, "New complaint recieved", mail) if err != nil { return err @@ -142,24 +172,12 @@ func SendPostMailToAdmins(email, postURL string) error { // Send email to peoples in the conversation thread expect the ignoreEmail // one, to prevent sending the mail to user itself for its events func SendMailToPeopleInThread(emails []string, ignoreEmail string, postURL string) error { - mail := fmt.Sprintf(` - - - - - - - -

cms: updates on your recent complaint

-

- View Updates -

- - - `, postURL) + mail := buildEmailHTML( + "cms: updates on a recent complaint", + "There has been an update on a complaint where you were mentioned.", + "View Updates", + postURL, + ) for _, email := range emails { if email == ignoreEmail { From 855b052be5f35230875ff1a795d2ecee4b9e342d Mon Sep 17 00:00:00 2001 From: ayush00git Date: Fri, 14 Aug 2026 14:22:23 +0530 Subject: [PATCH 2/2] fix: email body --- services/email.go | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/services/email.go b/services/email.go index 1afa6d2..c36403d 100644 --- a/services/email.go +++ b/services/email.go @@ -43,33 +43,54 @@ func buildEmailHTML(heading, message, buttonText, buttonURL string) string { + + %s + - + - +
- - + +
-
-

+

+

%s

-

+

%s

- @@ -80,15 +101,15 @@ func buildEmailHTML(heading, message, buttonText, buttonURL string) string { -
- + + %s
-

+

- +