forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

Error with tag img #322

Closed trangnt58 closed 5 years ago

trangnt58 commented 6 years ago

Please help me. I don't know why tag <img>not receive attribute src. My version:"email-templates": "^4.0.4" I add image in ejs <img src="images/mail/icons/img2.png" alt="img" width="16"> and config email:

const email = new Email({
    message: {
        from: config.MAIL_FROM
    },
    transport: smtpTransport,
    send: true,
    preview:false,
    views: {
        root: templateMailDir,
        options: {
            extension: 'ejs' 
        }
    },
    juiceResources: {
        webResources: {
            relativeTo: path.resolve(__dirname, '..'),
            images: true
        }
    }
});

But email that I received not have any image. Attribute src not exists.

capture

niftylettuce commented 6 years ago

Can you try running with DEBUG=* for more verbose output? I'm guessing it's just path issue. Might be related to #324.

ivanpetrus commented 5 years ago

hey there, i have a similar issue. basically i just want to send an email with fb icon at the bottom

Facebook

but gmail does not render it, if i open sources, email contains base64 string instead of url. So question, how can i configure email-template to use just url, not a base 64 string ?

niftylettuce commented 5 years ago

@ivanpetrus you should set images: true as the example here shows https://github.com/niftylettuce/email-templates/issues/322#issue-360780863 and you should also use the plugin I made https://www.npmjs.com/package/nodemailer-base64-to-s3 - this will take the base64 images and upload them to S3/CloudFront for CDN cache busting via revision hashes - and it will replace the base64 inline with image paths

kendallroth commented 3 years ago

Interestingly enough, the initial issue here is happening to me as well. I have verified that the path is correct by adding DEBUG=email-templates and checking that a warning occurs with a fake image path. Images with a correct path simply have their src tag completely removed, rather than encoding it or embedding. Any thoughts @niftylettuce ?