Send images via Nodemailer (Gmail compatible)

Here is the code to configure Nodemailer to send pics:

const mailConfig = {
    from: '',
    to:   '',
    subject: 'Important email - No, not really',
    attachments: [{
        filename: 'picture.png',
        path: __dirname + '/Assets/picture.png',
        cid: 'logo'
    html: `<b>Thanks for reading this important mail.</b>
           <p><img src = 'cid:logo'></img></p>`

Some things that I've tried and Gmail doesn't seem to support so far:

  1. Base64 pics
  2. SVG pics will be attached but won't be embedded
  3. External URLs in src won't display the picture

The conclusion is that the best approach seems to attach a png picture and use the cid as src.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.