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? |
Beta Was this translation helpful? Give feedback.
-
The same error: "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
I found this issue nest-modules/mailer#570, are you using @keithhuels as you mentiond adding |
Beta Was this translation helpful? Give feedback.
-
There is a comma "," missing in the compiler options. (In the article) "compilerOptions": {
"assets": ["mail/templates/**/*"] // 👈 missing comma
"watchAssets": true
} |
Beta Was this translation helpful? Give feedback.
-
Yes, it works now that I put "./" in front of the specific template I am using in the mail service. |
Beta Was this translation helpful? Give feedback.
-
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: |
Beta Was this translation helpful? Give feedback.
-
Thanks @parideis and @keithhuels for spotting, I updated the article! |
Beta Was this translation helpful? Give feedback.
-
if you're using EJS, make sure you set the strict mode to false in the config, |
Beta Was this translation helpful? Give feedback.
-
Try this in your mailservices.ts template: './templates/confirmation' |
Beta Was this translation helpful? Give feedback.
-
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.)? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 :/ |
Beta Was this translation helpful? Give feedback.
-
I had a problem where templates where copied to
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot ! |
Beta Was this translation helpful? Give feedback.
-
Hi, can you tell me how I could go about testing the mail module?
Here's the code excerpt:
|
Beta Was this translation helpful? Give feedback.
-
I am facing a weird error. When I provide credentials from environment I am getting this error export const mailConfig = { |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
What path do I have to shoot to test? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Nice article |
Beta Was this translation helpful? Give feedback.
-
I am facing with issue on localhost
|
Beta Was this translation helpful? Give feedback.
-
Hello, I got this error: /home/sambo/Developments/flashsapp_backend/node_modules/mailparser/node_modules/html-to-text/lib/html-to-text.cjs:1838 |
Beta Was this translation helpful? Give feedback.
-
How to handle the confirmation email after user click to confirm button at their email? |
Beta Was this translation helpful? Give feedback.
-
This is awesome, big thanks for the nice and understandable step-by-step snippets :) |
Beta Was this translation helpful? Give feedback.
-
Currently on the version, ^1.9.1.
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Send Emails with NestJS
Create Email Templates and send them with nodemailer from your Nest application
https://notiz.dev/blog/send-emails-with-nestjs
Beta Was this translation helpful? Give feedback.
All reactions