@zola_do/email 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -76
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
# @zola_do/email
|
|
2
|
-
|
|
3
|
-
Email service for NestJS applications with SMTP and Handlebars template support.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Install individually
|
|
9
|
-
npm install @zola_do/email
|
|
10
|
-
|
|
11
|
-
# Or via meta package
|
|
12
|
-
npm install @zola_do/nestjs-shared
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
### Module Setup
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { Module } from '@nestjs/common';
|
|
21
|
-
import { EmailModule } from '@zola_do/email';
|
|
22
|
-
|
|
23
|
-
@Module({
|
|
24
|
-
imports: [EmailModule],
|
|
25
|
-
})
|
|
26
|
-
export class AppModule {}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Sending Emails
|
|
30
|
-
|
|
31
|
-
Inject `EmailService` and send emails:
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { Injectable } from '@nestjs/common';
|
|
35
|
-
import { EmailService } from '@zola_do/email';
|
|
36
|
-
|
|
37
|
-
@Injectable()
|
|
38
|
-
export class NotificationService {
|
|
39
|
-
constructor(private readonly emailService: EmailService) {}
|
|
40
|
-
|
|
41
|
-
async sendWelcomeEmail(userEmail: string, userName: string) {
|
|
42
|
-
const body = `<h1>Welcome, ${userName}!</h1><p>Thanks for signing up.</p>`;
|
|
43
|
-
await this.emailService.sendEmail(userEmail, 'Welcome', body);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Handlebars Templates
|
|
49
|
-
|
|
50
|
-
The module uses `@nestjs-modules/mailer` with a Handlebars adapter. Place templates in `process.cwd() + '/templates/'` and use the MailerService directly for template-based emails (inject `MailerService` from `@nestjs-modules/mailer`).
|
|
51
|
-
|
|
52
|
-
### Verifying Connection
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
await this.emailService.verify();
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Environment Variables
|
|
59
|
-
|
|
60
|
-
| Variable | Description |
|
|
61
|
-
|----------|-------------|
|
|
62
|
-
| `EMAIL_SMTP` | SMTP host |
|
|
63
|
-
| `EMAIL_SMTP_PORT` | SMTP port |
|
|
64
|
-
| `EMAIL_SMTP_USERNAME` | SMTP username |
|
|
65
|
-
| `EMAIL_SMTP_PASSWORD` | SMTP password |
|
|
66
|
-
| `EMAIL_SMTP_DISPLAY_NAME` | From display name (defaults) |
|
|
67
|
-
|
|
68
|
-
## Exports
|
|
69
|
-
|
|
70
|
-
- `EmailModule` — Register the email module
|
|
71
|
-
- `EmailService` — Send emails and verify connection
|
|
72
|
-
- `EmailConfig` — Mailer configuration factory
|
|
73
|
-
|
|
74
|
-
## Related Packages
|
|
75
|
-
|
|
76
|
-
- [@zola_do/core](../core) — Shared types
|
|
1
|
+
# @zola_do/email
|
|
2
|
+
|
|
3
|
+
Email service for NestJS applications with SMTP and Handlebars template support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install individually
|
|
9
|
+
npm install @zola_do/email
|
|
10
|
+
|
|
11
|
+
# Or via meta package
|
|
12
|
+
npm install @zola_do/nestjs-shared
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Module Setup
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Module } from '@nestjs/common';
|
|
21
|
+
import { EmailModule } from '@zola_do/email';
|
|
22
|
+
|
|
23
|
+
@Module({
|
|
24
|
+
imports: [EmailModule],
|
|
25
|
+
})
|
|
26
|
+
export class AppModule {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Sending Emails
|
|
30
|
+
|
|
31
|
+
Inject `EmailService` and send emails:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { Injectable } from '@nestjs/common';
|
|
35
|
+
import { EmailService } from '@zola_do/email';
|
|
36
|
+
|
|
37
|
+
@Injectable()
|
|
38
|
+
export class NotificationService {
|
|
39
|
+
constructor(private readonly emailService: EmailService) {}
|
|
40
|
+
|
|
41
|
+
async sendWelcomeEmail(userEmail: string, userName: string) {
|
|
42
|
+
const body = `<h1>Welcome, ${userName}!</h1><p>Thanks for signing up.</p>`;
|
|
43
|
+
await this.emailService.sendEmail(userEmail, 'Welcome', body);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Handlebars Templates
|
|
49
|
+
|
|
50
|
+
The module uses `@nestjs-modules/mailer` with a Handlebars adapter. Place templates in `process.cwd() + '/templates/'` and use the MailerService directly for template-based emails (inject `MailerService` from `@nestjs-modules/mailer`).
|
|
51
|
+
|
|
52
|
+
### Verifying Connection
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
await this.emailService.verify();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Environment Variables
|
|
59
|
+
|
|
60
|
+
| Variable | Description |
|
|
61
|
+
|----------|-------------|
|
|
62
|
+
| `EMAIL_SMTP` | SMTP host |
|
|
63
|
+
| `EMAIL_SMTP_PORT` | SMTP port |
|
|
64
|
+
| `EMAIL_SMTP_USERNAME` | SMTP username |
|
|
65
|
+
| `EMAIL_SMTP_PASSWORD` | SMTP password |
|
|
66
|
+
| `EMAIL_SMTP_DISPLAY_NAME` | From display name (defaults) |
|
|
67
|
+
|
|
68
|
+
## Exports
|
|
69
|
+
|
|
70
|
+
- `EmailModule` — Register the email module
|
|
71
|
+
- `EmailService` — Send emails and verify connection
|
|
72
|
+
- `EmailConfig` — Mailer configuration factory
|
|
73
|
+
|
|
74
|
+
## Related Packages
|
|
75
|
+
|
|
76
|
+
- [@zola_do/core](../core) — Shared types
|