nest-modules / mailer

📨 A mailer module for Nest framework (node.js)
https://nest-modules.github.io/mailer/
MIT License
837 stars 175 forks source link

My template is not loaded? #1081

Open vladimirteddy opened 8 months ago

vladimirteddy commented 8 months ago

My config in app.module.ts: MailerModule.forRoot({ transport: { host: 'smtp.gmail.com', port: 587, ignoreTLS: false, secure: false, auth: { user: process.env.GMAIL_USER, pass: process.env.GMAIL_PASS, }, }, defaults: { from: '"No Reply" <info@xxxxxxx>', }, // preview: true, template: { dir: process.cwd() + '/src/templates/', adapter: new HandlebarsAdapter(), options: { strict: true, }, }, }),

My config in sendMail: const sendMail = await this._mailerService.sendMail({ to: user.email, subject: "Confirm Your Email Address", context: { name: 'my name' }, template: 'my-template', });

My mail account receives mail but there is no template. "@nestjs-modules/mailer": "^1.6.0" "nodemailer": "^6.7.0"

amitailanciano commented 8 months ago

I had the same issue, turns out it was due to the css-inline dependency throwing an error because of Google fonts in my template. The error is currently ignored in an empty try/catch block in the handlebars adapter, it should probably call the callback function and pass the error in the catch block instead.

you can work around it by disabling inline css in the second argument of the handlebar adapter instantiation.

see https://github.com/Stranger6667/css-inline/issues/264

vladimirteddy commented 8 months ago

Thanks for your suggest. I fixed it by loading the template manually.

Simolation commented 8 months ago

I also have this issue that the email is just empty without any exception or anything, and it used to work flawlessly before the 1.10 update. Disabling the inline css { inlineCssEnabled: false } fixed the problem for me.

LeCongNam commented 8 months ago

Thank you @amitailanciano { inlineCssEnabled: false } work with me.

Stranger6667 commented 7 months ago

FYI, the WASM version of css-inline will get support for fetching external resources over the network, as soon as https://github.com/Stranger6667/css-inline/pull/320 is done (it will use fetch internally)