Using Embedded Images

Attachments can be used as embedded images in the HTML body. To use this feature, you need to set additional property of the attachment – cid (unique identifier of the file) which is a reference to the attachment file. The same cid value must be used as the image URL in HTML (using cid: as the URL protocol, see example below).

NB! the cid value should be as unique as possible!

var mailOptions = {
    ...
    html: 'Embedded image: <img src="cid:[email protected]"/>',
    attachments: [{
        filename: 'image.png',
        path: '/path/to/file',
        cid: [email protected]' //same cid value as in the html img src
    }]
}