简体   繁体   中英

EISDIR: illegal operation on a directory, read + Nodemailer image attachment

I just wanted to know how to specify the path in attachments in Nodemailer. I am getting this above-mentioned error. Can anyone specify how to specify the path?

var imagePath = path.join(__dirname, '/images/')

attachments : [{ filename: "Header@3x.png", path: ${imagePath} , cid: 'headerImage' }]

I had the same problem. But I resolved by giving the full path till Image.

For example:

var imagePath = path.join(__dirname, '/images/Header@3x.png'); // In this line, Give the full path of image.
attachments : [{
              filename: "Header@3x.png",
              path:${imagePath},         // __dirname+'/images/Header@3x.png'
              cid: 'headerImage'
}]

And your HTML will be :

<div>
   <img src="cid:headerImage" alt="Header Image" width="100" height="100"/>
</div>

( In the path IMAGE_NAME is important and required.)

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