From 3845a8f02b201c87b83fa4e963ac30220a7c8afe Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 17 Jan 2017 15:34:50 +0100 Subject: [PATCH] HTMLify user added email to admins --- src/mail_templates/user_added.ejs | 35 +++++++++++++++++++++++++++-- src/mail_templates/welcome_user.ejs | 4 ++-- src/mailer.js | 13 ++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/mail_templates/user_added.ejs b/src/mail_templates/user_added.ejs index d9866872c..f049c0939 100644 --- a/src/mail_templates/user_added.ejs +++ b/src/mail_templates/user_added.ejs @@ -1,8 +1,8 @@ <%if (format === 'text') { %> -Hi <%= cloudronName %> Admin, +Dear <%= cloudronName %> Admin, -User with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>. +A new user with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>. <% if (inviteLink) { %> As requested, this user has not been sent an invitation email. @@ -12,7 +12,38 @@ To set a password and perform any configuration on behalf of the user, please us <% } %> + +Powered by https://cloudron.io + <% } else { %> +
+ + + +

Dear <%= cloudronName %> Admin,

+ +

+ A new user with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>. +

+ +<% if (inviteLink) { %> +

+ As requested, this user has not been sent an invitation email.
+
+ Set a password and perform any configuration on behalf of the user +

<% } %> +
+
+ +
+ Powered by Cloudron. +
+ +
+ + + +<% } %> diff --git a/src/mail_templates/welcome_user.ejs b/src/mail_templates/welcome_user.ejs index 5c12a8f4b..130754e1d 100644 --- a/src/mail_templates/welcome_user.ejs +++ b/src/mail_templates/welcome_user.ejs @@ -1,6 +1,6 @@ <%if (format === 'text') { %> -Hi <%= user.displayName || user.username || user.alternateEmail || user.email %>, +Dear <%= user.displayName || user.username || user.alternateEmail || user.email %>, Welcome to <%= cloudronName %>! @@ -12,7 +12,7 @@ You are receiving this email because you were invited by <%= invitor.email %>. <% } %> -Powered by Cloudron.io +Powered by https://cloudron.io <% } else { %> diff --git a/src/mailer.js b/src/mailer.js index 57613e54e..ef252c705 100644 --- a/src/mailer.js +++ b/src/mailer.js @@ -290,15 +290,22 @@ function userAdded(user, inviteSent) { fqdn: config.fqdn(), user: user, inviteLink: inviteSent ? null : config.adminOrigin() + '/api/v1/session/account/setup.html?reset_token=' + user.resetToken, - format: 'text', - cloudronName: cloudronName + cloudronName: cloudronName, + cloudronAvatarUrl: config.adminOrigin() + '/api/v1/cloudron/avatar' }; + var templateDataText = JSON.parse(JSON.stringify(templateData)); + templateDataText.format = 'text'; + + var templateDataHTML = JSON.parse(JSON.stringify(templateData)); + templateDataHTML.format = 'html'; + var mailOptions = { from: mailConfig().from, to: adminEmails.join(', '), subject: util.format('%s: user %s added', cloudronName, user.alternateEmail || user.email), - text: render('user_added.ejs', templateData) + text: render('user_added.ejs', templateData), + html: render('user_added.ejs', templateDataHTML) }; enqueue(mailOptions);