@cinnabun/mail 0.0.1 → 0.0.7
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 +67 -0
- package/dist/mail.module.d.ts +2 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @cinnabun/mail
|
|
2
|
+
|
|
3
|
+
Email module for Cinnabun. SMTP delivery with Handlebars templates.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @cinnabun/mail
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { CinnabunApp, CinnabunFactory } from "@cinnabun/core";
|
|
15
|
+
import { MailModule, MailPlugin, SmtpAdapter } from "@cinnabun/mail";
|
|
16
|
+
|
|
17
|
+
@CinnabunApp({
|
|
18
|
+
port: 3000,
|
|
19
|
+
scanPaths: [],
|
|
20
|
+
imports: [
|
|
21
|
+
MailModule.forRoot({
|
|
22
|
+
adapter: SmtpAdapter,
|
|
23
|
+
smtp: {
|
|
24
|
+
host: process.env.SMTP_HOST ?? "localhost",
|
|
25
|
+
port: 587,
|
|
26
|
+
secure: false,
|
|
27
|
+
auth: {
|
|
28
|
+
user: process.env.SMTP_USER,
|
|
29
|
+
pass: process.env.SMTP_PASS,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
plugins: [new MailPlugin()],
|
|
35
|
+
})
|
|
36
|
+
class App {}
|
|
37
|
+
|
|
38
|
+
CinnabunFactory.run(App);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Sending email
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { MailService } from "@cinnabun/mail";
|
|
45
|
+
|
|
46
|
+
@Service()
|
|
47
|
+
class NotificationService {
|
|
48
|
+
constructor(private mail: MailService) {}
|
|
49
|
+
|
|
50
|
+
async sendWelcome(to: string, name: string) {
|
|
51
|
+
await this.mail.send({
|
|
52
|
+
to,
|
|
53
|
+
subject: "Welcome",
|
|
54
|
+
html: await this.mail.render("welcome", { name }),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Adapters
|
|
61
|
+
|
|
62
|
+
- **SmtpAdapter** — SMTP delivery
|
|
63
|
+
- **ConsoleAdapter** — Logs to console (development)
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
package/dist/mail.module.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type Constructor } from "@cinnabun/core";
|
|
1
2
|
import type { MailModuleOptions } from "./interfaces/mail-options.js";
|
|
2
3
|
import type { MailAdapter } from "./interfaces/mail-adapter.js";
|
|
3
4
|
import { MailPlugin } from "./mail.plugin.js";
|
|
4
5
|
export declare class MailModule {
|
|
5
|
-
static forRoot(options: MailModuleOptions):
|
|
6
|
+
static forRoot(options: MailModuleOptions): Constructor;
|
|
6
7
|
static getOptions(): MailModuleOptions;
|
|
7
8
|
static createAdapter(): MailAdapter;
|
|
8
9
|
static createPlugin(): MailPlugin;
|