diff --git a/src/mail_templates/password_reset-html.ejs b/src/mail_templates/password_reset-html.ejs
new file mode 100644
index 000000000..3928b433a
--- /dev/null
+++ b/src/mail_templates/password_reset-html.ejs
@@ -0,0 +1,24 @@
+
+
+
+
+{{ passwordResetEmail.salutation }}
+
+{{ passwordResetEmail.description }}
+
+
+ {{ passwordResetEmail.resetAction }}
+
+
+
+
+{{ passwordResetEmail.expireNote }}
+
+
+
+
+
+
+
diff --git a/src/mail_templates/password_reset-text.ejs b/src/mail_templates/password_reset-text.ejs
new file mode 100644
index 000000000..67e4c1f35
--- /dev/null
+++ b/src/mail_templates/password_reset-text.ejs
@@ -0,0 +1,9 @@
+{{ passwordResetEmail.salutation }}
+
+{{ passwordResetEmail.description }}
+
+{{ passwordResetEmail.resetActionText }}
+
+{{ passwordResetEmail.expireNote }}
+
+Powered by https://cloudron.io
diff --git a/src/mail_templates/password_reset.ejs b/src/mail_templates/password_reset.ejs
deleted file mode 100644
index e157601cb..000000000
--- a/src/mail_templates/password_reset.ejs
+++ /dev/null
@@ -1,45 +0,0 @@
-<%if (format === 'text') { %>
-
-Hi <%= user.displayName || user.username || user.email %>,
-
-Someone, hopefully you, has requested your account's password
-be reset. If you did not request this reset, please ignore this message.
-
-To reset your password, please visit the following page:
-<%- resetLink %>
-
-Please note that the password reset link will expire in 24 hours.
-
-Powered by https://cloudron.io
-
-<% } else { %>
-
-
-
-
-
-Hi <%= user.displayName || user.username || user.email %>,
-
-
- Someone, hopefully you, has requested your account's password be reset.
- If you did not request this reset, please ignore this message.
-
-
-
- Click to reset your password
-
-
-
-
-Please note that the password reset link will expire in 24 hours.
-
-
-
-
-
-
-
-
-<% } %>
diff --git a/src/mailer.js b/src/mailer.js
index 38b508098..8aa9269ed 100644
--- a/src/mailer.js
+++ b/src/mailer.js
@@ -227,28 +227,26 @@ function passwordReset(user) {
getMailConfig(function (error, mailConfig) {
if (error) return debug('Error getting mail details:', error);
- var templateData = {
- user: user,
- resetLink: `${settings.adminOrigin()}/login.html?resetToken=${user.resetToken}`,
- cloudronName: mailConfig.cloudronName,
- cloudronAvatarUrl: settings.adminOrigin() + '/api/v1/cloudron/avatar'
- };
+ translation.getTranslations(function (error, translationAssets) {
+ if (error) return debug('Error getting translations:', error);
- var templateDataText = JSON.parse(JSON.stringify(templateData));
- templateDataText.format = 'text';
+ var templateData = {
+ user: user.displayName || user.username || user.email,
+ resetLink: `${settings.adminOrigin()}/login.html?resetToken=${user.resetToken}`,
+ cloudronName: mailConfig.cloudronName,
+ cloudronAvatarUrl: settings.adminOrigin() + '/api/v1/cloudron/avatar'
+ };
- var templateDataHTML = JSON.parse(JSON.stringify(templateData));
- templateDataHTML.format = 'html';
+ var mailOptions = {
+ from: mailConfig.notificationFrom,
+ to: user.fallbackEmail,
+ subject: `[${mailConfig.cloudronName}] Password Reset`,
+ text: render('password_reset-text.ejs', templateData, translationAssets),
+ html: render('password_reset-html.ejs', templateData, translationAssets)
+ };
- var mailOptions = {
- from: mailConfig.notificationFrom,
- to: user.fallbackEmail,
- subject: util.format('[%s] Password Reset', mailConfig.cloudronName),
- text: render('password_reset.ejs', templateDataText),
- html: render('password_reset.ejs', templateDataHTML)
- };
-
- sendMail(mailOptions);
+ sendMail(mailOptions);
+ });
});
}