Repository navigation
Send Emails with NestJS #167
Replies: 43 comments 26 replies
|
I am getting an exception : "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined. Any idea what to do? |
|
The same error: "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined |
|
Do you have a repo to reproduce this error? Does this error occure in this example https://github.com/notiz-dev/nestjs-mailer for you as well? |
|
I found this issue nest-modules/mailer#570, are you using @keithhuels as you mentiond adding |
|
There is a comma "," missing in the compiler options. (In the article) "compilerOptions": {
"assets": ["mail/templates/**/*"] // 👈 missing comma
"watchAssets": true
} |
|
Yes, it works now that I put "./" in front of the specific template I am using in the mail service. |
|
Another quick note, you have a "USER_FROM" in the .env file but it's not being used in the service. I believe it should be: from: |
|
Thanks @parideis and @keithhuels for spotting, I updated the article! |
|
if you're using EJS, make sure you set the strict mode to false in the config, |
|
Try this in your mailservices.ts template: './templates/confirmation' |
|
First off, great tutorial! I followed it start to finish with no hiccups. Have you found a way to include template styling other than inlining them (partials, linking to static assets, etc.)? |
|
Hi, I do have one question though: Is there a way to separate out styling files (.css) or do I have to define styling in the handlebars files? I tried extracting the styling in a style.css file in the same directory as the handlebars file, but it seem like it isn't resolved properly. I have checked, that the .css file is also transported into the dist folder. |
|
Hi, I'm having some trouble with the template part of things though. first of template seems to not go where they would be supposed to in the dist folder. it comes out as : Dist Wich is kinda strange, and not consistent with what you've got on the tutorial. I've tried tinkering around with no luck :/ |
|
I had a problem where templates where copied to
|
Thanks a lot ! |
|
Hello, thank you very much for the tutorial, I cloned the project in https://github.com/notiz-dev/nestjs-mailer, but I can't get it to work locally, what is the path to do the test? |
|
Hi, can you tell me how I could go about testing the mail module? Here's the code excerpt: |
|
I am facing a weird error. When I provide credentials from environment I am getting this error export const mailConfig = { |
|
Having trouble with testing like @pblan above. I've followed the same code example in the blog post but then made this basic test spec. // mail.service.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { MailService } from './mail.service';
import { MailerModule } from '@nestjs-modules/mailer';
describe('MailService', () => {
let service: MailService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [MailerModule],
providers: [MailService],
}).compile();
service = module.get<MailService>(MailService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});I get the dreaded I've tried various things like including Handbars and path in the imports section (although I don't think they are required) without much success. Any help would be appreciated |
|
What path do I have to shoot to test? |
|
I got an issue: And I watched an error message and found the compile path is not correct. Instead of using {
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"assets": ["mail/templates/**/*"],
"watchAssets": true
}
}You can specify the path like below, and it work for me. {
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"assets": [
{
"include": "mail/template/**/*",
"outDir": "dist/src"
}
],
"watchAssets": true
}
}Hope this can help. |
|
Nice article |
|
I am facing with issue on localhost |
|
Hello, I got this error: /home/sambo/Developments/flashsapp_backend/node_modules/mailparser/node_modules/html-to-text/lib/html-to-text.cjs:1838 |
|
How to handle the confirmation email after user click to confirm button at their email? |
|
hello |
|
This is awesome, big thanks for the nice and understandable step-by-step snippets :) |
|
Currently on the version, ^1.9.1.
|
|
Error: And after looking at a solution, currently the nest-cli.json looks like the below but still the same error, earlier it was same as the above code and was getting the same error. |
|
I am getting the same error in sep 2023. it says TypeError: Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined. i have tried everything. file structure is like this. src/templates/acton.hbs below is my nest.cli.json this is app.module.ts this is mailing.service.ts |
Uh oh!
There was an error while loading. Please reload this page.
Send Emails with NestJS
Create Email Templates and send them with nodemailer from your Nest application
https://notiz.dev/blog/send-emails-with-nestjs
All reactions