Closed nwkeeley closed 7 years ago
Writing a test for this now to see what's wrong.
@nwkeeley please download v3.1.3 via npm install email-templates@latest
or yarn add email-templates@latest
. the email.render
function now uses juiceResources
(previously only email.send
did). there is also an exposed email.juiceResources
function you can use if you want to write a custom render
function. see the docs at https://github.com/niftylettuce/email-templates#custom-rendering-eg-from-a-mongodb-database if necessary. lmk of any questions, and thanks for filing the issue.
@nwkeeley also note that previewEmail
does not parse attachments
array like Nodemailer does.
This means that if you're not using email.send
, and you want preview-email
to work, you'll need to use it like this:
const previewEmail = require('preview-email');
const nodemailer = require('nodemailer');
const transport = nodemailer.createTransport({
jsonTransport: true
});
// <https://nodemailer.com/message/>
const message = {
from: 'niftylettuce+from@gmail.com',
to: 'niftylettuce+to@gmail.com',
subject: 'Hello world',
html: '<p>Hello world</p>',
text: 'Hello world',
attachments: [ { filename: 'hello-world.txt', content: 'Hello world' } ]
};
transport.sendMail(message).then(res => {
message = JSON.parse(res.message);
previewEmail(message).then(console.log).catch(console.error);
}).catch(console.error);
I've updated preview-email
README at https://github.com/niftylettuce/preview-email to note of this:
@niftylettuce Awesome - thank you for the quick turn around - great module and great support!
Hi,
Upgrading from v2 to v3
If I am only using the email.render() method to pass rendered HTML to my SendGrid module will I not be able to use juiceResources?
I have my .ejs and .css in the same folder and it doesn't seem to be inlining the styles like described here: https://github.com/niftylettuce/email-templates#automatic-inline-css-via-stylesheets
in my .ejs file I have