Reputation: 196
I am able to send static email to fix mail id with fix content , how to make it dynamic in nodemailer .
transporter.sendMail({
from: '[email protected]',
to: '[email protected]',
subject: 'Ashutosh Jha : credentials',
text: 'hello how are you'
});
Upvotes: 1
Views: 1628
Reputation: 196
It is working now thankyou
var mailcontent = ({
from: '[email protected]',
to: email,
subject: 'AJ : credentials',
html: 'Dear '+docs[0]['name'] + ',<br/><br/>here is your credentials : <br/><br/><br/><b> username :'+docs[0]['username']+'<br/> password : '+docs[0]['password']+'</b><br/><br/> Thanks and regards , <br/> AJ'
});
transporter.sendMail(mailcontent , function(err , success){
if(err)
{
res.render('forget-password',{
error : err
});
}else {
res.render('index',{
success : 'Information succesfully sent to "' + email+'"'
});
}
});
Upvotes: 0
Reputation: 1236
A few options.
var body = 'Hello ' + name + ', how are you?';
var sprintf = require('sprintf-js').sprintf;
var body2 = sprintf('Hello %s, how are you?', name);
Or you could use a template engine like Swig or HandleBars.
Upvotes: 3