To display an image in an email generated with Nodemailer, I use the attachments method:
var mailOptions = {
from: this.senderEmail,
to: this.receiverEmail,
subject: subject,
html: content,
attachments: [
{
filename: "source_text_white.png",
path: __dirname + "/assets/images/source_text_white.png",
cid: "im_logo_source_text",
},
...
HTML:
<img src="cid:im_logo_source_text" alt="Logo Source App" width="200" style="display: block; margin-left: auto; margin-right: auto" loading="lazy"/>
The image appears in the email, it works very well. The problem is the following, the image is also displayed as an attachment in the mail, see the example below on Gmail.
Maybe I am not using the correct method to display images from files on the server. But is there a way for the image to be visible in the email but not as an attachment?
