email template
This commit is contained in:
parent
4bbcde4fbb
commit
99607dd9aa
290
main.go
290
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(`
|
||||
<p>Hello,</p>
|
||||
<p>Click on the link below to reset your password.</p>
|
||||
@ -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(`
|
||||
<html>
|
||||
<body>
|
||||
<p>Dear %s,</p>
|
||||
<p>A new user has registered and is awaiting your review.</p>
|
||||
<p><strong>Details:</strong></p>
|
||||
<p>Name: %s<br>
|
||||
Email: %s</p>
|
||||
<p>Please review the registration and take appropriate action:</p>
|
||||
<p>
|
||||
<a href="https://pb.venbait.in/api/custom/approve?userId=%s" style="padding: 10px 15px; background-color: green; color: white; text-decoration: none; border-radius: 5px;">Approve</a>
|
||||
<a href="https://pb.venbait.in/api/custom/reject?userId=%s" style="padding: 10px 15px; background-color: red; color: white; text-decoration: none; border-radius: 5px;">Reject</a>
|
||||
</p>
|
||||
<p>Thank you,</p>
|
||||
<img src="%s" alt="FCSC Logo" style="width:150px; height:auto;">
|
||||
</body>
|
||||
</html>
|
||||
`, 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(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Registration Update – UAE Stats App</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f8f8f8;">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0" align="center">
|
||||
<tr>
|
||||
<td align="center" style="padding: 20px;">
|
||||
<table role="presentation" width="600px" cellspacing="0" cellpadding="0" border="0" style="background-color: #ffffff; border: 2px solid #d1ad5c; padding: 20px;">
|
||||
<tr>
|
||||
<td align="center" style="font-size: 18px; font-weight: bold;">
|
||||
<span style=" font-size:16px; border-bottom:1px solid #d1ad5c">
|
||||
تسجيل مستخدم جديد - تطبيق إحصاءات الإمارات العربية المتحدة - قيد المراجعة<br>
|
||||
</span>
|
||||
<br><span style="font-size: 18px;">New User Registration - UAE Stats App - Pending Review</span>
|
||||
<br><br><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; font-size: 12px; padding-bottom:30px">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td align="left" style="width: 56%%; vertical-align: top;">
|
||||
<strong>Dear <span style="color: #d1ad5c;">%s</span>,</strong><br><br>
|
||||
A new user has registered on UAE Stats Mobile app and is awaiting your review.
|
||||
<br><br>
|
||||
<strong>Details:</strong><br>
|
||||
Name: %s<br>
|
||||
Email: <a href="mailto:%s" style="color: #d1ad5c; text-decoration: none;">%s</a>
|
||||
<br><br>
|
||||
Please review the registration and take appropriate action.
|
||||
<br><br>
|
||||
<a href="https://pb.venbait.in/api/custom/approve?userId=%s" style="background-color: green; color: white; padding: 5px 10px; border: none; cursor: pointer; border-radius:4px; font-size: 10px;">Approve ✅</a>
|
||||
<a href="https://pb.venbait.in/api/custom/reject?userId=%s" style="background-color: red; color: white; padding: 5px 10px; border: none; cursor: pointer; border-radius:4px; font-size: 10px;">Reject ❌</a>
|
||||
</td>
|
||||
<td align="right" style="width: 42%%; vertical-align: top; direction: rtl; text-align: right;">
|
||||
<strong>عزيزي <span style="color: #d1ad5c;">%s</span>،</strong><br><br>
|
||||
تم تسجيل مستخدم جديد في تطبيق إحصاءات الإمارات وهو في انتظار مراجعتك.
|
||||
<br><br>
|
||||
<strong>التفاصيل:</strong><br>
|
||||
الاسم: %s<br>
|
||||
البريد الإلكتروني: <a href="mailto:%s" style="color: #d1ad5c; text-decoration: none;">%s</a>
|
||||
<br><br>
|
||||
يرجى مراجعة التسجيل واتخاذ الإجراء المناسب.
|
||||
<br><br>
|
||||
<a href="https://pb.venbait.in/api/custom/reject?userId=%s" style="background-color: red; color: white; padding: 5px 10px; border: none; cursor: pointer; border-radius:4px; font-size: 10px;">❌ Reject</a>
|
||||
<a href="https://pb.venbait.in/api/custom/approve?userId=%s" style="background-color: green; color: white; padding: 5px 10px; border: none; cursor: pointer; border-radius:4px; font-size: 10px;">✅ Approve</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" padding-top: 20px;">
|
||||
<img src="https://imageats.s3.ap-south-1.amazonaws.com/signature.png" alt="We The UAE 2031" width="100%%">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; font-size: 12px; color: #777; border-top: 1px solid #ccc;">
|
||||
<strong>تنويه:</strong> المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً.
|
||||
<br><br>
|
||||
<strong>Disclaimer:</strong> 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.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
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(`
|
||||
<p>Dear %s,</p>
|
||||
<p>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.</p>
|
||||
<p>Please access your account using the following link: <a href="http://your-login-url.com"> Access Your Account</a>.</p>
|
||||
<p>If you have any questions, please feel free to contact us for further clarification.</p>
|
||||
</br>
|
||||
<p>Best regards,</p>
|
||||
<img src="%s" alt="FCSC Logo" style="width:150px; height:auto;">
|
||||
`, userName, logoURL)
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Registration Update – UAE Stats App</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f8f8f8;">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0" align="center">
|
||||
<tr>
|
||||
<td align="center" style="padding: 20px;">
|
||||
<table role="presentation" width="600px" cellspacing="0" cellpadding="0" border="0" style="background-color: #ffffff; border: 2px solid #d1ad5c; padding: 20px;">
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" style="font-size: 18px; font-weight: bold;">
|
||||
<span style=" font-size:18px; border-bottom:1px solid #d1ad5c">
|
||||
تمت الموافقة على التسجيل - إحصاءات الإمارات العربية المتحدة<br>
|
||||
</span><br><span style="font-size: 18px;">Registration Approved – UAE Statistics App</span>
|
||||
<br><br><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; font-size: 12px;">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td align="left" style="width: 56%%; vertical-align: top;">
|
||||
<strong>Dear <span style="color: #d1ad5c;">%s</span>,</strong><br><br>
|
||||
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.
|
||||
<br><br>
|
||||
Please access your account using the following link: <a href="https://www.fcsc.com/login" style="color: #d1ad5c; text-decoration: none;">Login</a>.
|
||||
<br><br>
|
||||
If you have any questions or believe this decision was made in error, please feel free to contact us for further clarification.
|
||||
</td>
|
||||
<td align="right" style="width: 42%%; vertical-align: top; direction: rtl; padding-bottom:30px">
|
||||
<strong>عزيزي <span style="color: #d1ad5c;">%s</span>،</strong><br><br>
|
||||
يسرنا إبلاغك بأنه تمت الموافقة على تسجيلك في تطبيق إحصاءات الإمارات. يمكنك الآن تسجيل الدخول باستخدام بيانات الاعتماد التي أنشأتها.
|
||||
<br><br>
|
||||
يرجى الوصول إلى حسابك عبر الرابط التالي <a href="#" style="color: #d1ad5c; text-decoration: none;">[URL]</a>.
|
||||
<br><br>
|
||||
إذا كانت لديك أي استفسارات أو كنت تعتقد أن هذا القرار خاطئ، فلا تتردد في التواصل معنا لمزيد من التوضيح.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" padding-top: 20px;">
|
||||
<img src="https://imageats.s3.ap-south-1.amazonaws.com/signature.png" alt="We The UAE 2031" width="100%">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; font-size: 12px; color: #777; border-top: 1px solid #ccc;">
|
||||
<strong>تنويه:</strong> المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً.
|
||||
<br><br>
|
||||
<strong>Disclaimer:</strong> 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.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
`, userName, userName)
|
||||
} else if newStatus == "Denied" {
|
||||
subject = "Registration Update – FCSC"
|
||||
body = fmt.Sprintf(`
|
||||
<p>Dear %s,</p>
|
||||
<p>Thank you for registering with FCSC. After careful review, we regret to inform you that your registration has not been approved at this time.</p>
|
||||
<p>If you have any questions or believe this decision was made in error, please feel free to contact us for further clarification.</p>
|
||||
<p>We appreciate your understanding and thank you for your interest.</p>
|
||||
</br>
|
||||
<p>Best regards,</p>
|
||||
<img src="%s" alt="FCSC Logo" style="width:150px; height:auto;">
|
||||
`, userName, logoURL)
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Registration Update – UAE Stats App</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f8f8f8;">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0" align="center">
|
||||
<tr>
|
||||
<td align="center" style="padding: 20px;">
|
||||
<table role="presentation" width="600px" cellspacing="0" cellpadding="0" border="0" style="background-color: #ffffff; border: 2px solid #d1ad5c; padding: 20px;">
|
||||
<tr>
|
||||
<td align="center" style="font-size: 18px; font-weight: bold;">
|
||||
<span style=" font-size:16px; border-bottom:1px solid #d1ad5c">
|
||||
تحديث التسجيل – تطبيق إحصاءات الإمارات العربية المتحدة<br>
|
||||
</span><br><span style="font-size: 18px;">Registration Update – UAE Stats App</span>
|
||||
<br><br><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; padding-bottom:30px; font-size: 12px;">
|
||||
<table role="presentation" width="100%%" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td align="left" style="width: 56%%; vertical-align: top;">
|
||||
<strong>Dear <span style="color: #d1ad5c;">%s</span>,</strong><br><br>
|
||||
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.
|
||||
<br><br>
|
||||
If you have any questions or believe this decision was made in error, please feel free to <a href="#" style="color: #d1ad5c; text-decoration: none; font-weight: bold;">contact us</a> for further clarification.
|
||||
<br><br>
|
||||
We appreciate your understanding and thank you for your interest.
|
||||
</td>
|
||||
<td align="right" style="width: 42%%; vertical-align: top; direction: rtl;">
|
||||
<strong>عزيزي <span style="color: #d1ad5c;">%s</span>،</strong><br><br>
|
||||
نشكرك على تسجيلك في تطبيق إحصاءات الإمارات. بعد مراجعة دقيقة، نأسف لإبلاغك بأن تسجيلك لم يتم الموافقة عليه في هذا الوقت.
|
||||
<br><br>
|
||||
إذا كان لديك أي أسئلة أو كنت تعتقد أن هذا القرار خاطئ، فلا تتردد في التواصل معنا لمزيد من التوضيح.
|
||||
<br><br>
|
||||
نقدّر تفهمك ونشكرك على اهتمامك.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" padding-top: 20px;">
|
||||
<img src="https://imageats.s3.ap-south-1.amazonaws.com/signature.png" alt="We The UAE 2031" width="100%%">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 20px; font-size: 12px; color: #777; border-top: 1px solid #ccc;">
|
||||
<strong>تنويه:</strong> المعلومات الواردة في هذه الرسالة الإلكترونية والمرفقات الخاصة بها سرية وقد تكون محمية بموجب القانون. إذا لم تكن الشخص المعني باستلام هذه الرسالة، فيرجى إخطار المرسل وحذف هذه الرسالة فوراً.
|
||||
<br><br>
|
||||
<strong>Disclaimer:</strong> 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.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
`, 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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user