How to send images in the body of my mailgun template with nodejs

Viewed 604

I am integrating the mailgun API services to send transactional emails, this is my code:

import mailgun from "mailgun-js"
const DOMAIN = "sandboxxxxxxxx.mailgun.org";
const mg = mailgun({apiKey: "xxxxxx-xxxxx-xxxxx", domain: DOMAIN});
const filename = path.join(__dirname, 'assets/meme.png')
const data = {
    from: "Mailgun Sandbox <postmaster@sandboxxxxxxxx.mailgun.org>",
    to: "xxxxx@gmail.com",
    subject: "Test email",
  html: '<div><img src="cd:meme.png"/><h1>Thank you for choosing Mailgun!</h1></div>',
  inline: filename
};
mg.messages().send(data, function (error: any, body: any) {
  if(error){console.log(error)} console.log(body);
});

I try to send an image in my html body, but when I receive the email, it does not arrive in the body, but as a downloadable attachment. I would also like to send more than one image in the body of the body of my template. any ideas ?

I appreciate your help in advance

0 Answers
Related