简体   繁体   中英

Nodemailer - how add attachment to template email in jade

I don't know how use embedded images in email, utilizing attachments.

I have in .js:

var mailOptions = { ... html: 'my html jade', attachments: [{ filename: 'image.png', path: '/picture/file', cid: 'myPicture' //same cid value as in the html img src }]

In jade file:

... img(src="cid:myPicture")

When i send my email .... This not work. I have added attachment in the e-mail, but message do not have embedded images.

Whoa! Super old question. You've either figured it out or quit programming by now. When I ran into the same problem, Google led me here.

It all comes down to the path. I had to set the absolute path including the file name . So, in your case, it would all look like this:

var mailOptions = {
  // ...
  html: 'my html jade',
  attachments: [{
  filename: 'image.png',
  path: '/picture/file/image.png',
  cid: 'myPicture' //same cid value as in the html img src
}]

I can't speak for the jade stuff, but hopefully this will help some other Nodemailer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM