I have this text here:
var text1 = '<p>Hey ' + rows[i].NAME + ', \n\nFrom our team here at Indera Technologies ...
I send it like this through html
parameter in nodemailer transporter:
var text1 = '<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><p>Hey ' + rows[i].NAME + ', \n\nFrom our team here at Pier Solutions, we wanted to let you know that we have done a little re-branding. We have changed our name to... drum roll please! \n\nIndera Technologies!</p>'
var text2 = '</body></html>'
// send mail with defined transport object
let sendBatch = await transporter.sendMail({
from: "solutionspier@gmail.com", // sender address
to: rows[i].EMAIL,
// bcc: emails, // list of receivers
subject: "It's Official, we've rebranded!", // Subject line
html: text1 + req.body.htmlContent + text2
});
then when I send the email, it actually shows up in the email like this:
Hey Gianluca From our team here at Indera Technologies
it does all one line instead of new line.
how do I fix this?
If this is supposed to be part of HTML, use the <br>
tag instead of \n
.
Or better yet, put the lower text in a separate <p>
tag
Also, you might want to learn about Template Literals, it's going to make writing strings like that much easier