Mail Template using Handlebars
juanmartin opened this issue · comments
Hi, I'm using the mail-time module to handle queues in case of loss of internet connection.
I think I got it working fine, the issue I'm having is related to the template file for the email I need to send.
When creating a new MailTime object I define:
template: './views/mail.handlebars'
When I send the email I get the error:
Error: html nor text field is presented, at least one those fields is required.
But if I define text or html it overrides the template. How can I overcome this?
Thank you for your great work!
Cheers
JM
Hello @juanmartin ,
You have to use plaintext (String) as a value for template
option.
The error you're experiencing seems to be unrelated to a Template, please double-check html
or text
field is passed to sendMail
method.
Feel free to close it in case if the issue is solved on your end.
Hello @dr-dimitru
OK now I've seen the example in test.js I understand.
The thing is that my client needs the template to be a separate file so they can edit it easier.
Is there a way to call this file? I've been using nodemailer-express-handlebars to render an external .handlebars file.
In fact, I have it in my transport object:
transporter.use('compile', hbs({
viewEngine: {
extName: '.handlebars',
partialsDir: './views',
layoutsDir: './views',
defaultLayout: 'mail.handlebars',
},
viewPath: './views',
extName: '.handlebars',
}));
Still, it won't use this. Help plsss!
Compile template out of SNMP chain, before sending an email and pass it as a String to sendMail(...) method
Closed due to silence at issue owner end.
Feel free to reopen it in case if the issue still persists on your end.