javascript - Hide other reciepient in to address while sending email using nodeemailer -
i working on emailsender project using node.js. found nodeemailer package making easier.
but when sending email multiple contacts , contact seeing other contact addresses in column.
i want hide others receiver. receiver see email address only.
the code using is,
var mailoptions = { from: 'sender@sender.com', // sender address to: 'reciever1@domain.com,reciever1@domain.com', // list of receivers subject: 'hello', // subject line text: 'hello world', // plaintext body html: '<b>hello world</b>' // html body }; transporter.sendmail(mailoptions, function(error, info) { if (error) { res.send(error); } else { res.send('message sent: ' + res); } });
the question when receiver1 gets email, should not know receiver2 got same email.
thanks.
store listofrecipients in array , loop through them
var listofrecipients = ["reciever1 <reciever1@domain.com>", "reciever2 <reciever2@domain.com>"] (var = 0; < listofrecipients.length; i++) { var mailoptions = { from: 'sender <sender@sender.com>', // sender address to: listofrecipients[i], // list of receivers subject: 'hello', // subject line text: 'hello world', // plaintext body html: '<b>hello world</b>' // html body }; transporter.sendmail(mailoptions, function(error, info) { if (error) { res.send(error); } else { res.send('message sent: ' + res); } }); }
Comments
Post a Comment