Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should this work with nodemailer's embedded images using the 'cid' parameter? #31

Closed
Kopfy opened this issue Feb 17, 2016 · 5 comments
Closed

Comments

@Kopfy
Copy link

Kopfy commented Feb 17, 2016

emailHelper.templates.render('email_test.html', context, function (err, html, text) {
emailHelper.transporter.sendMail({
from: 'xy@gmail.com',
to: 'yy@gmail.com',
subject: 'Testmail',
html: html,
//text: text
attachments: [{
filename: 'logo.jpg',
path: '../../public/img',
cid: 'logouniquecid' //same cid value as in the html img src
}]
});
});

Settings:
var templates = new EmailTemplates({
root: global.appRoot + '/server/templates',
text: false, // Disable text alternatives
swig: {
cache: false // Don't cache swig templates
}
});

In email_test.html

<img class="img-responsive" src="cid:logouniquecid"/>

The cid value is the same as should be... however, I always get the rendered mail with inline CSS and the image, but I always get the following error:

Not found, skipping: cid:logouniquecid

@takkaria
Copy link
Collaborator

Hm, I agree that this shouldn't throw an error. It's not this package that prints it, it's way up the stack in https://www.npmjs.com/package/web-resource-inliner. For now you will have to put up with it, but I will see if there is a way to avoid this with patches upstream.

@Kopfy
Copy link
Author

Kopfy commented Feb 19, 2016

Hi!

Thank you!

Br,
Marko

On 18 February 2016 at 15:15, Andi Sidwell notifications@github.com wrote:

Hm, I agree that this shouldn't throw an error. It's not this package that
prints it, it's way up the stack in
https://www.npmjs.com/package/web-resource-inliner. For now you will have
to put up with it, but I will see if there is a way to avoid this with
patches upstream.


Reply to this email directly or view it on GitHub
#31 (comment)
.

@catamphetamine
Copy link

catamphetamine commented Sep 27, 2016

I wonder if cid is the way to go.
I read this article and it proposed three variants: CID, embedded base64 and CDN.
https://sendgrid.com/blog/embedding-images-emails-facts/
I tried base64 but it simply said Not found, skipping: data:image/png;base64,....
So apparently it parses <img src/> attribute and doesn't recognise the data: scheme.
I may try to use CID too.

  • Update: yes, it's working with cid for Gmail web client (and the warning is shown too, though it's working)
    (It's for a logo)

@takkaria
Copy link
Collaborator

web-resource-inliner won't touch URLs it doesn't understand, just throw a warning. So if you use a data: url it won't remove it but it might say it doesn't understand it.

However, there's not much point in putting the image in a data: url yourself. You might as well keep it separate on the filesystem for easier modification and let web-resource-inliner turn it into a data: URL for you.

@takkaria
Copy link
Collaborator

This has been fixed upstream (see jrit/web-resource-inliner#21) so I will update dependencies soon and then this warning will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants