You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot change templating engine in User.verify() e-mails #1138
The ejs templating engine is hardcoded into the loopback core (loopback.template function), and User.verify() uses it when sending confirmation e-mail to users, so I cannot use any other templating engine.
Are you trying to use a different templating engine when using User.verify? Or for the entire app? Please create a test project on Github to reproduce the issue as per https://github.com/strongloop/loopback/wiki/Issues#bug-report and I will verify your issue.
I'm quite new to Loopback, so maybe I'm doing something wrong. I've tried to use different templating engines for the entire app (jade and handlebar so far), but they don't affect the e-mail sent from User.verify.
Hi,
one of the possible reasons that the template is hard-coded is for ease of use for many users. You can change the text of the email body in models/user.js .. If there is a better suggestion for the loopback,template function, please submit a PR. Thanks.
For the possibility of using handlebars, jade, mandrill, I will get back to you on that.
For the possibility of using handlebars, jade, mandrill, I will get back to you on that.
I am in the process of using Mandril as an e-mail service. But in now way it seems possible to use Mandril since I cannot pass the mandrill template via the options to user.verify().
Do we have a solution for this, or will I be implementing a custom verification script?
@kwuite the user.verify() method calling the Email.send() to send the mail, the send method is implemented in the User model to use nodemailer. If you'd like to use another e-mail sender library, you can just simply write your own verify method by using your own mailer. The verify method is just to send out an email with the confirm endpoint token, and then you may write a context.res.redirect(301, "path") to your destination after sending out the verification email.
+1, the way verify() generates the email's html body is very hard to
extend as it can only relies on loopback.template().
What would you think of a additional templateFn option ?
It would be especially useful when one has a template engine specific for
email that can't rely on loopback.template(like https://github.com/
crocodilejs/node-email-templates for CSS inlining)
Activity
superkhau commentedon Feb 26, 2015
Are you trying to use a different templating engine when using
User.verify? Or for the entire app? Please create a test project on Github to reproduce the issue as per https://github.com/strongloop/loopback/wiki/Issues#bug-report and I will verify your issue.mirow commentedon Feb 27, 2015
I'm quite new to Loopback, so maybe I'm doing something wrong. I've tried to use different templating engines for the entire app (jade and handlebar so far), but they don't affect the e-mail sent from User.verify.
Correct me if I'm wrong, but it does look to me like this piece of code is hard-coded to always use ejs as a templating engine?:
https://github.com/strongloop/loopback/blob/master/lib/loopback.js#L176-L190
stringbeans commentedon May 8, 2015
+1
Not sure why loopback is hardcoded to use ejs with loopback.template()
arne-s commentedon Jun 28, 2015
Same problem here, I try to use Mandrill, which stores its templates on the server, however I can't get around these default settings.
raabbajam commentedon Jul 7, 2015
👍 trying to use jade. Maybe check extension of template, or just default to whatever set in app
app.set('view engine', 'jade');shbhsngh commentedon Nov 24, 2015
facing the same problem. don't know, why loopback is not giving option to change verification email body?
Fabrik19SH commentedon Mar 20, 2016
Hi, this point is still valid. Is there a workaround for using handlebars?
Many thanks
loay commentedon Apr 7, 2016
Hi,
one of the possible reasons that the template is hard-coded is for ease of use for many users. You can change the text of the email body in
models/user.js.. If there is a better suggestion for theloopback,templatefunction, please submit a PR. Thanks.For the possibility of using handlebars, jade, mandrill, I will get back to you on that.
elbarto132 commentedon Apr 21, 2016
+1
pmoelgaard commentedon Apr 22, 2016
+1
rpalacio86 commentedon Jun 13, 2016
+1
adanmuguirofoo commentedon Jun 28, 2016
+1
kwuite commentedon Sep 30, 2016
@loay
I am in the process of using Mandril as an e-mail service. But in now way it seems possible to use Mandril since I cannot pass the mandrill template via the options to user.verify().
Do we have a solution for this, or will I be implementing a custom verification script?
zhenyanghua commentedon Sep 30, 2016
@kwuite the user.verify() method calling the
Email.send()to send the mail, the send method is implemented in theUsermodel to usenodemailer. If you'd like to use another e-mail sender library, you can just simply write your own verify method by using your own mailer. The verify method is just to send out an email with theconfirmendpoint token, and then you may write acontext.res.redirect(301, "path")to your destination after sending out the verification email.kwuite commentedon Sep 30, 2016
@zhenyanghua, thank you for your reply.
I resolved the issue by generating the token and then calling user.save so I can proceed with the call to mandrill.
adrien-k commentedon Nov 11, 2016
+1, the way
verify()generates the email's html body is very hard to extend as it can only rely onloopback.template().What would you think of a additional
templateFnoption ?It would be especially useful when one has a template engine specific for email that can't rely on
loopback.template(like https://github.com/crocodilejs/node-email-templates for CSS inlining)zhenyanghua commentedon Nov 11, 2016
If you use es6 in node, you can really just use
${}to write thetemplate, it is really flexible.
Zhenyang Hua
On Fri, Nov 11, 2016 at 9:24 AM, adrien-k notifications@github.com wrote:
ritch commentedon Nov 29, 2016
This is possible now. Closing.