From 99607dd9aa823a02b2d91e7e0483c48ff21f923a Mon Sep 17 00:00:00 2001 From: venbaittech Date: Thu, 3 Apr 2025 12:23:05 +0530 Subject: [PATCH] email template --- main.go | 290 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 226 insertions(+), 64 deletions(-) diff --git a/main.go b/main.go index addcac7..a8ae248 100644 --- a/main.go +++ b/main.go @@ -607,7 +607,9 @@ func main() { // Send email subject := "Reset your FCSC password" - resetURL := fmt.Sprintf("%s/api/auth/reset-password?token=%s", baseUrl, token) + // resetURL := fmt.Sprintf("%s/api/auth/reset-password?token=%s", baseUrl, token) + resetURL := fmt.Sprintf("https://www.fcsc.com/forgot-password/%s", email) + body := fmt.Sprintf(`

Hello,

Click on the link below to reset your password.

@@ -2237,46 +2239,93 @@ func sendAdminEmail(app *pocketbase.PocketBase, userID, username, userEmail stri adminName := "Admin" subject := "New User Registration Pending Review" - // Fetch the image file URL from the PocketBase collection - imageRecord, err := app.Dao().FindFirstRecordByData("images", "file_name", "app_logo") - if err != nil { - log.Printf("Failed to fetch logo from images collection: %v", err) - return nil - } - - // Construct the logo URL - logoURL := fmt.Sprintf("%s/api/files/images/%s/%s", - baseUrl, - imageRecord.Id, - imageRecord.GetString("file"), - ) - - body := fmt.Sprintf(` - - -

Dear %s,

-

A new user has registered and is awaiting your review.

-

Details:

-

Name: %s
- Email: %s

-

Please review the registration and take appropriate action:

-

- Approve - Reject -

-

Thank you,

- FCSC Logo - - - `, adminName, username, userEmail, userID, userID, logoURL) - + // Fetch the email configuration from PocketBase emailConfig, err := app.Dao().FindFirstRecordByData("email_configuration", "type", "admin_receive_mail") if err != nil { log.Printf("Failed to fetch email configuration: %v", err) - return nil + return err } adminEmail := emailConfig.GetString("email") + // Construct email body + body := fmt.Sprintf(` + + + + + + Registration Update – UAE Stats App + + + + + + +
+ + + + + + + + + + + + + +
+ + تسجيل مستخدم جديد - تطبيق إحصاءات الإمارات العربية المتحدة - قيد المراجعة
+
+
New User Registration - UAE Stats App - Pending Review +


+
+ + + + + +
+ Dear %s,

+ A new user has registered on UAE Stats Mobile app and is awaiting your review. +

+ Details:
+ Name: %s
+ Email: %s +

+ Please review the registration and take appropriate action. +

+ Approve ✅ + Reject ❌ +
+ عزيزي %s،

+ تم تسجيل مستخدم جديد في تطبيق إحصاءات الإمارات وهو في انتظار مراجعتك. +

+ التفاصيل:
+ الاسم: %s
+ البريد الإلكتروني: %s +

+ يرجى مراجعة التسجيل واتخاذ الإجراء المناسب. +

+ ❌ Reject + ✅ Approve +
+
+ We The UAE 2031 +
+ تنويه: المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً. +

+ Disclaimer: The information contained and transmitted within this email message is PRIVILEGED AND/OR CONFIDENTIAL. If you are not the intended recipient, please notify the sender and delete this email immediately. +
+
+ + + `, + adminName, username, userEmail, userEmail, userID, userID, + adminName, username, userEmail, userEmail, userID, userID) + // Send email message := &mailer.Message{ From: mail.Address{ @@ -2292,7 +2341,7 @@ func sendAdminEmail(app *pocketbase.PocketBase, userID, username, userEmail stri if err := app.NewMailClient().Send(message); err != nil { log.Printf("Failed to send admin email: %v", err) - return nil + return err } log.Println("Admin email sent successfully.") @@ -2302,48 +2351,161 @@ func sendAdminEmail(app *pocketbase.PocketBase, userID, username, userEmail stri func sendStatusChangeEmail(app *pocketbase.PocketBase, record *models.Record, newStatus string) error { userEmail := record.GetString("email") userName := record.GetString("uname") + log.Printf("userName: %s", userName) if userEmail == "" { return fmt.Errorf("user email is empty") } - imageRecord, err := app.Dao().FindFirstRecordByData("images", "file_name", "app_logo") - if err != nil { - log.Printf("Failed to fetch logo from images collection: %v", err) - return nil - } + // imageRecord, err := app.Dao().FindFirstRecordByData("images", "file_name", "app_logo") + // if err != nil { + // log.Printf("Failed to fetch logo from images collection: %v", err) + // return nil + // } - // Construct the logo URL - logoURL := fmt.Sprintf("%s/api/files/images/%s/%s", - baseUrl, - imageRecord.Id, - imageRecord.GetString("file"), - ) + // // Construct the logo URL + // logoURL := fmt.Sprintf("%s/api/files/images/%s/%s", + // baseUrl, + // imageRecord.Id, + // imageRecord.GetString("file"), + // ) var subject, body string if newStatus == "Approved" { subject = "Registration Approved – FCSC" body = fmt.Sprintf(` -

Dear %s,

-

We are pleased to inform you that your registration with FCSC has been approved. You can now log in using the credentials that you had created.

-

Please access your account using the following link: Access Your Account.

-

If you have any questions, please feel free to contact us for further clarification.

-
-

Best regards,

- FCSC Logo - `, userName, logoURL) + + + + + + Registration Update – UAE Stats App + + + + + + +
+ + + + + + + + + + + + + + + +
+ + تمت الموافقة على التسجيل - إحصاءات الإمارات العربية المتحدة
+

Registration Approved – UAE Statistics App +


+
+ + + + + +
+ Dear %s,

+ We are pleased to inform you that your registration with UAE Stats app has been approved. You can now log in using the credentials that you had created. +

+ Please access your account using the following link: Login. +

+ If you have any questions or believe this decision was made in error, please feel free to contact us for further clarification. +
+ عزيزي %s،

+ يسرنا إبلاغك بأنه تمت الموافقة على تسجيلك في تطبيق إحصاءات الإمارات. يمكنك الآن تسجيل الدخول باستخدام بيانات الاعتماد التي أنشأتها. +

+ يرجى الوصول إلى حسابك عبر الرابط التالي [URL]. +

+ إذا كانت لديك أي استفسارات أو كنت تعتقد أن هذا القرار خاطئ، فلا تتردد في التواصل معنا لمزيد من التوضيح. +
+
+ We The UAE 2031 +
+ تنويه: المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً. +

+ Disclaimer: The information contained and transmitted within this email message is PRIVILEGED AND/OR CONFIDENTIAL. If you are not the intended recipient, please notify the sender and delete this email immediately. +
+
+ + + `, userName, userName) } else if newStatus == "Denied" { subject = "Registration Update – FCSC" body = fmt.Sprintf(` -

Dear %s,

-

Thank you for registering with FCSC. After careful review, we regret to inform you that your registration has not been approved at this time.

-

If you have any questions or believe this decision was made in error, please feel free to contact us for further clarification.

-

We appreciate your understanding and thank you for your interest.

-
-

Best regards,

- FCSC Logo - `, userName, logoURL) + + + + + + Registration Update – UAE Stats App + + + + + + +
+ + + + + + + + + + + + + +
+ + تحديث التسجيل – تطبيق إحصاءات الإمارات العربية المتحدة
+

Registration Update – UAE Stats App +


+
+ + + + + +
+ Dear %s,

+ Thank you for registering with UAE Stats Mobile App. After careful review, we regret to inform you that your registration has not been approved at this time. +

+ If you have any questions or believe this decision was made in error, please feel free to contact us for further clarification. +

+ We appreciate your understanding and thank you for your interest. +
+ عزيزي %s،

+ نشكرك على تسجيلك في تطبيق إحصاءات الإمارات. بعد مراجعة دقيقة، نأسف لإبلاغك بأن تسجيلك لم يتم الموافقة عليه في هذا الوقت. +

+ إذا كان لديك أي أسئلة أو كنت تعتقد أن هذا القرار خاطئ، فلا تتردد في التواصل معنا لمزيد من التوضيح. +

+ نقدّر تفهمك ونشكرك على اهتمامك. +
+
+ We The UAE 2031 +
+ تنويه: المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً. +

+ Disclaimer: The information contained and transmitted within this email message is PRIVILEGED AND/OR CONFIDENTIAL. If you are not the intended recipient, please notify the sender and delete this email immediately. +
+
+ + + `, userName, userName) } else { // If the status is neither "Approved" nor "Denied", skip sending an email return nil @@ -2365,7 +2527,7 @@ func sendStatusChangeEmail(app *pocketbase.PocketBase, record *models.Record, ne HTML: body, } - err = app.NewMailClient().Send(message) + err := app.NewMailClient().Send(message) if err != nil { return fmt.Errorf("failed to send email: %v", err) }