Nodemailer: Image displayed as attachment

Viewed 313

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.

Screenshot 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?

1 Answers

In my case my attachment was size of 200kb something. I added one with much smaller size , around 15kb and it worked.

Related