Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email with node JS [closed]

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/

like image 444
anonym Avatar asked May 25 '26 05:05

anonym


2 Answers

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!

like image 130
James111 Avatar answered May 26 '26 18:05

James111


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.

like image 37
weiyin Avatar answered May 26 '26 17:05

weiyin