Gmail displays embedded images as base64 string

Viewed 503

I'm using pug, email-templates and nodemailer-ses-transport to send emails from node.js through AWS SES. Email preview looks good, but test emails I'm receiving in the Gmail web client is completely messed up as image is not converted back from base64 string, and it's displayed as html:

enter image description here

It seems to be problem with Gmail only since in the Mac Mail client it looks fine. Sometimes, email is correctly displayed, but without image.

I've tried to use linked image stored on S3, but Gmail is stripping out src and image is not displayed.

It doesn't happen for the other emails I'm receiving, e.g. notifications from Strava.

The only way I could display is through the use of CID:

const email = new Email({
    message: {
        from: config.EMAIL_FROM, // sender address
        attachments: [
            {
                filename: 'logo.png',
                path: `${resources}/logo.png`,
                cid: 'logo',
            },
        ],
    },
    send: true,
    transport,
    juice: true,
    preview:false,
    juiceResources: {
        preserveImportant: true,
        webResources: {
            images: false,
            relativeTo: `${config.TEMPLATES_DIR}/assets`,
        },
    },
});

However, I don't like this solution as image appears as attachment in the email.

Any suggestion how to properly embed images so it can be accessed everywhere. I saw multiple similar discussions similar to this and some of the recent discussions suggests that Gmail is now supporting embedded images.

0 Answers
Related