Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in node.js mailer template

Tags:

node.js

mailer

I'm using node.js mailer module to send email from node server. I used template file for that but I got all spaces trimmed when the message was sent. I tried to add '\n' at the end line of the template but it doesn't work also. Here is an example of template file:

Hi {{username}},\\n

Thanks for creating an account with us

I tried \n and \n , nothing all doesn't work. Any help?

Thanks,

like image 996
Feras Odeh Avatar asked Nov 25 '25 06:11

Feras Odeh


1 Answers

nodemailer supports two types of templates, i.e. text and html (or templateFn() - case of loopback).

The option text is used for email clients which don't support HTML rendering so that \n should be used in this option for a new line.

On the contrary, you should swap \n with <br> in the option html.

Hope this would help you.

like image 73
egor518 Avatar answered Nov 27 '25 22:11

egor518



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!