Wednesday, 10 May 2017

nodemailer html message strips the text from fs reader

I am reading a text file content like this:

fs.readFile(__dirname +'/' +'/myfile.txt', 'utf8', function (err, data) {
        if (err) {
            throw err;
        }
        mycontent = data
        console.log("print here:",mycontent)
    })

and then I pass it to the nodemailer as the html message :

var mailMessage = '<p>' + mycontent + '</p>';

but when the email is sent, the content of the text file loses its line breaks in the email message. How can I preserve it?

original text content:

Sed ut perspiciatis unde 
omnis iste natus error sit 
voluptatem accusantium doloremque 
laudantium, totam rem aperiam, 
eaque ipsa quae ab illo 
inventore veritatis

current outcome is like:

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis

the purpose is to perseve the original line breaks.



via passion

No comments:

Post a Comment