Always use default template
mixalistzikas opened this issue · 1 comments
mixalistzikas commented
I have the following settings with nodemailer
this.mailer.use('compile', hbs({
viewEngine: {
extname: '.hbs',
layoutsDir: 'src/emails/',
partialsDir: 'src/emails/',
defaultLayout: 'new_message_from_shooter.hbs',
},
viewPath: 'src/emails/',
extName: '.hbs'
}));
When I call this
this.mailer.sendMail({
from: `info@photoshooter.gr>`,
to: 'to@photoshooter.gr',
subject: `Test message user`, // Subject line
template: 'new_message_from_user',
context: {
a: 1
}
});
or this
this.mailer.sendMail({
from: `info@photoshooter.gr>`,
to: 'to@photoshooter.gr',
subject: `Test message shooter`, // Subject line
template: 'new_message_from_shooter',
context: {
a: 1
}
});
I always get the same template.... "new_message_from_shooter"
Any ideas?
colfax4 commented
In case others encounter this (as I did), here's what I did to get it to work:
transporter.use('compile', hbs({
viewEngine: {
extName: '.hbs',
partialsDir: './helpers/templates/',
// layoutsDir: './helpers/templates/',
defaultLayout: false,
},
viewPath: './helpers/templates/',
extName: '.hbs',
}));
The key here being the "defaultLayout: false". It's still unclear to me how one would actually utilize a defaultLayout while overriding it during "sendMail" since, as the issue description suggests, it appears to always use the defaultLayout when specified. Luckily, this is not my usecase. 😄