I'm looking for a way to send mail with node js. My mail has html content that needs to be styled (I need to set the font-family and the color). I also need to put a image for the logo.
I already tried to use nodemailer but when I try to style my content it doesn't work, when I also try to link an image (for the logo) it doesn't work. Does anyone have an issue ?
If you have an other way than node mailer please tell me.
https://nodemailer.com/
Checkout mailgun:
https://github.com/bojand/mailgun-js
It's really easy to setup and use! Here's a snippet from their documentation:
var filepath = path.join(__dirname, 'mailgun_logo.png');
var file = fs.readFileSync(filepath);
var data = {
from: 'Excited User <[email protected]>',
to: '[email protected]',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!',
attachment: file
};
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
You can do a lot with the package, includes the ability to attach files!
Email client support for CSS styles varies. In particular, many clients do not allow you to put styles into a css block; they must be inline directly with the elements. You can use something like juice to process your html to inline the styles.
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