Monday 30 March 2020

Email-Templates: They look Completely Different and I have no idea why

I need to be able to send invoices over email, which is why I turned to npm email-templates. Now, when it shows me a preview it's exactly the way I want it. However, when I actually send the email and view the results, it comes with all of the content but the css is completely messed up. Here is the code used to send it ``` const Email = require('email-templates'); const nodemailer = require('nodemailer'); // ---- Content here removed for privacy (auth obj, testdata obj) ------ let transportInstance = nodemailer.createTransport({ service: 'gmail', auth })const email = new Email({ message: { from: auth.user }, send: true, transport: transportInstance })function invoiceEmail(custEmail, custInvoice){ email.send({ template: 'invoices', message: { to: custEmail }, locals: { companyName: custInvoice.invoicer.firstName, invoice: custInvoice } }) .then() .catch(console.error); } `` I am using Pug as recommended byemail-templates` and, as I said, it looks fine in the preview. I sent an email to both Yahoo and GMail to look for changes, but they were both a mess and identical in that mess.

Submitted March 30, 2020 at 06:17PM by sinithw

No comments:

Post a Comment