Closed Laurensdc closed 6 years ago
Try set option send: true
.
@Laurensdc can you please share code from serverBoot.js
?
According to src/index.js
it should automatically send and should also automatically stop the previews in non-development environments. My guess is that your NODE_ENV
is somehow getting defaulted or overridden?
https://github.com/niftylettuce/email-templates/blob/master/src/index.js#L57-L58
A not related question, how to set a different path of the templates? I just tried to use views: { root: path.join(__dirname, '..', 'server', 'emails') }
and it is just ignored.
I was having issues getting mail to send as well. Here's what worked for me:
const Email = require('email-templates');
const nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail'
});
const email = new Email({
message: {
from: config.emailFrom
},
send: true,
transport: transporter,
//textOnly: true,
preview: false,
});
email
.send({
template: 'ads_found',
message: {
to: config.emailTo
},
locals: {
ads: adsToEmail
}
})
.then(console.log)
.catch(console.error);
I'm assuming you guys all solved your issues?
If you still have problems, you can run your app with DEBUG=email-templates
or DEBUG=*
before it, e.g. DEBUG=* node app.js
.
Let me know if we can be of more help in debugging!
I'm starting my backend with
NODE_ENV=production DEBUG=email-templates node serverBoot.js
. I keep getting redirected to a preview window with the email, instead of the email actually sending. Terminal is also not outputting any information.