Does anyone know how to tell Node.js´ module nodemailer to use an external HTML file (with links to stylesheets) as email content?
I am able to type in HTML tags as email content but I prefer loading complete HTML files. I´m using nodemailer 1.3.0.
Unfortunately I can´t find any example covering this issue for the actual nodemailer version.
Ideas?
In server. js , add the following code, which will trigger sending an email: const hbs = require('nodemailer-express-handlebars') const nodemailer = require('nodemailer') const path = require('path') // initialize nodemailer var transporter = nodemailer.
In short, what you need to do to send messages, would be the following: Create a Nodemailer transporter using either SMTP or some other transport mechanism. Set up message options (who sends what to whom) Deliver the message object using the sendMail() method of your previously created transporter.
You should use inline css, not a separate file since HTML rendering of head elements and such are defined by provider not by nodemailer.
I'd recomend mailChim's css inliner tool, it's pretty handy, just set the
html: '<div style="font - family: verdana; max-width:500px; margin-left">' + 'more string and string'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With