@arikajs/mail 0.0.1
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/LICENSE +21 -0
- package/README.md +290 -0
- package/dist/Contracts/Transport.d.ts +4 -0
- package/dist/Contracts/Transport.d.ts.map +1 -0
- package/dist/Contracts/Transport.js +3 -0
- package/dist/Contracts/Transport.js.map +1 -0
- package/dist/MailManager.d.ts +13 -0
- package/dist/MailManager.d.ts.map +1 -0
- package/dist/MailManager.js +69 -0
- package/dist/MailManager.js.map +1 -0
- package/dist/Mailable.d.ts +21 -0
- package/dist/Mailable.d.ts.map +1 -0
- package/dist/Mailable.js +32 -0
- package/dist/Mailable.js.map +1 -0
- package/dist/Mailer.d.ts +31 -0
- package/dist/Mailer.d.ts.map +1 -0
- package/dist/Mailer.js +89 -0
- package/dist/Mailer.js.map +1 -0
- package/dist/Message.d.ts +45 -0
- package/dist/Message.d.ts.map +1 -0
- package/dist/Message.js +77 -0
- package/dist/Message.js.map +1 -0
- package/dist/Transport/ArrayTransport.d.ts +14 -0
- package/dist/Transport/ArrayTransport.d.ts.map +1 -0
- package/dist/Transport/ArrayTransport.js +25 -0
- package/dist/Transport/ArrayTransport.js.map +1 -0
- package/dist/Transport/LogTransport.d.ts +5 -0
- package/dist/Transport/LogTransport.d.ts.map +1 -0
- package/dist/Transport/LogTransport.js +12 -0
- package/dist/Transport/LogTransport.js.map +1 -0
- package/dist/Transport/MailgunTransport.d.ts +8 -0
- package/dist/Transport/MailgunTransport.d.ts.map +1 -0
- package/dist/Transport/MailgunTransport.js +24 -0
- package/dist/Transport/MailgunTransport.js.map +1 -0
- package/dist/Transport/SendGridTransport.d.ts +8 -0
- package/dist/Transport/SendGridTransport.d.ts.map +1 -0
- package/dist/Transport/SendGridTransport.js +22 -0
- package/dist/Transport/SendGridTransport.js.map +1 -0
- package/dist/Transport/SesTransport.d.ts +8 -0
- package/dist/Transport/SesTransport.d.ts.map +1 -0
- package/dist/Transport/SesTransport.js +28 -0
- package/dist/Transport/SesTransport.js.map +1 -0
- package/dist/Transport/SmtpTransport.d.ts +8 -0
- package/dist/Transport/SmtpTransport.d.ts.map +1 -0
- package/dist/Transport/SmtpTransport.js +30 -0
- package/dist/Transport/SmtpTransport.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/src/Contracts/Transport.d.ts +4 -0
- package/dist/src/Contracts/Transport.d.ts.map +1 -0
- package/dist/src/Contracts/Transport.js +3 -0
- package/dist/src/Contracts/Transport.js.map +1 -0
- package/dist/src/MailManager.d.ts +13 -0
- package/dist/src/MailManager.d.ts.map +1 -0
- package/dist/src/MailManager.js +69 -0
- package/dist/src/MailManager.js.map +1 -0
- package/dist/src/Mailable.d.ts +21 -0
- package/dist/src/Mailable.d.ts.map +1 -0
- package/dist/src/Mailable.js +32 -0
- package/dist/src/Mailable.js.map +1 -0
- package/dist/src/Mailer.d.ts +31 -0
- package/dist/src/Mailer.d.ts.map +1 -0
- package/dist/src/Mailer.js +89 -0
- package/dist/src/Mailer.js.map +1 -0
- package/dist/src/Message.d.ts +45 -0
- package/dist/src/Message.d.ts.map +1 -0
- package/dist/src/Message.js +77 -0
- package/dist/src/Message.js.map +1 -0
- package/dist/src/Transport/ArrayTransport.d.ts +14 -0
- package/dist/src/Transport/ArrayTransport.d.ts.map +1 -0
- package/dist/src/Transport/ArrayTransport.js +25 -0
- package/dist/src/Transport/ArrayTransport.js.map +1 -0
- package/dist/src/Transport/LogTransport.d.ts +5 -0
- package/dist/src/Transport/LogTransport.d.ts.map +1 -0
- package/dist/src/Transport/LogTransport.js +12 -0
- package/dist/src/Transport/LogTransport.js.map +1 -0
- package/dist/src/Transport/MailgunTransport.d.ts +8 -0
- package/dist/src/Transport/MailgunTransport.d.ts.map +1 -0
- package/dist/src/Transport/MailgunTransport.js +24 -0
- package/dist/src/Transport/MailgunTransport.js.map +1 -0
- package/dist/src/Transport/SendGridTransport.d.ts +8 -0
- package/dist/src/Transport/SendGridTransport.d.ts.map +1 -0
- package/dist/src/Transport/SendGridTransport.js +22 -0
- package/dist/src/Transport/SendGridTransport.js.map +1 -0
- package/dist/src/Transport/SesTransport.d.ts +8 -0
- package/dist/src/Transport/SesTransport.d.ts.map +1 -0
- package/dist/src/Transport/SesTransport.js +28 -0
- package/dist/src/Transport/SesTransport.js.map +1 -0
- package/dist/src/Transport/SmtpTransport.d.ts +8 -0
- package/dist/src/Transport/SmtpTransport.d.ts.map +1 -0
- package/dist/src/Transport/SmtpTransport.js +30 -0
- package/dist/src/Transport/SmtpTransport.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +46 -0
- package/dist/src/index.js.map +1 -0
- package/dist/tests/Mail.test.d.ts +2 -0
- package/dist/tests/Mail.test.d.ts.map +1 -0
- package/dist/tests/Mail.test.js +43 -0
- package/dist/tests/Mail.test.js.map +1 -0
- package/dist/tests/TransportResolution.test.d.ts +2 -0
- package/dist/tests/TransportResolution.test.d.ts.map +1 -0
- package/dist/tests/TransportResolution.test.js +52 -0
- package/dist/tests/TransportResolution.test.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ArikaJs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
## Arika Mail
|
|
2
|
+
|
|
3
|
+
`@arikajs/mail` is the email delivery system for the ArikaJS framework.
|
|
4
|
+
|
|
5
|
+
It provides a driver-based, configurable mailer with support for templated emails, attachments, and queue-ready delivery — inspired by Laravel Mail but built natively for Node.js and TypeScript.
|
|
6
|
+
|
|
7
|
+
This package allows applications to send emails without coupling to a specific transport.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- **Multiple mailers**: Configure different mail transports (SMTP)
|
|
14
|
+
- **Driver-based transport system**: Pluggable email backends
|
|
15
|
+
- **Class-based Mailables**: Reusable email classes
|
|
16
|
+
- **Templated emails**: Using `@arikajs/view` for rendering
|
|
17
|
+
- **Attachments**: Via `@arikajs/storage` integration
|
|
18
|
+
- **Plain text & HTML emails**: Support for both formats
|
|
19
|
+
- **Queue-ready architecture**: Designed for async delivery
|
|
20
|
+
- **TypeScript-first**: Full type safety with JavaScript support
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 📦 Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @arikajs/mail
|
|
28
|
+
# or
|
|
29
|
+
yarn add @arikajs/mail
|
|
30
|
+
# or
|
|
31
|
+
pnpm add @arikajs/mail
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
### Sending a Basic Email
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { Mail } from '@arikajs/mail';
|
|
42
|
+
|
|
43
|
+
await Mail.to('user@example.com')
|
|
44
|
+
.subject('Welcome')
|
|
45
|
+
.text('Welcome to ArikaJS!')
|
|
46
|
+
.send();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📬 Using Email Templates
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
await Mail.to('user@example.com')
|
|
55
|
+
.subject('Welcome')
|
|
56
|
+
.view('emails.welcome', { user })
|
|
57
|
+
.send();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Templates are rendered using `@arikajs/view`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ✉️ Mailables (Recommended)
|
|
65
|
+
|
|
66
|
+
Mailables provide a clean, reusable way to define emails.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { Mailable } from '@arikajs/mail';
|
|
70
|
+
|
|
71
|
+
export class WelcomeMail extends Mailable {
|
|
72
|
+
constructor(private user: any) {
|
|
73
|
+
super();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
build() {
|
|
77
|
+
return this
|
|
78
|
+
.subject('Welcome to ArikaJS')
|
|
79
|
+
.view('emails.welcome', { user: this.user });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Sending a mailable:**
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
await Mail.to(user.email).send(new WelcomeMail(user));
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 📎 Attachments
|
|
93
|
+
|
|
94
|
+
Attach files using Arika Storage:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await Mail.to('user@example.com')
|
|
98
|
+
.subject('Invoice')
|
|
99
|
+
.attach('invoices/2024.pdf')
|
|
100
|
+
.send();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## ⚙️ Configuration
|
|
106
|
+
|
|
107
|
+
Mail configuration is defined via the application config:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
export default {
|
|
111
|
+
default: process.env.MAIL_MAILER || 'log',
|
|
112
|
+
|
|
113
|
+
mailers: {
|
|
114
|
+
smtp: {
|
|
115
|
+
transport: 'smtp',
|
|
116
|
+
host: process.env.MAIL_HOST || 'smtp.mailtrap.io',
|
|
117
|
+
port: Number(process.env.MAIL_PORT || 587),
|
|
118
|
+
username: process.env.MAIL_USERNAME,
|
|
119
|
+
password: process.env.MAIL_PASSWORD,
|
|
120
|
+
encryption: process.env.MAIL_ENCRYPTION || 'tls',
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
log: {
|
|
124
|
+
transport: 'log',
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
array: {
|
|
128
|
+
transport: 'array',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
from: {
|
|
133
|
+
address: process.env.MAIL_FROM_ADDRESS || 'hello@example.com',
|
|
134
|
+
name: process.env.MAIL_FROM_NAME || 'Example',
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🚚 Supported Transports (v1)
|
|
142
|
+
|
|
143
|
+
| Transport | Status | Description |
|
|
144
|
+
| :--- | :--- | :--- |
|
|
145
|
+
| **SMTP** | ✅ Supported | Standard SMTP delivery |
|
|
146
|
+
| **Log** | ✅ Supported | Logs emails to console (for local dev) |
|
|
147
|
+
| **Array** | ✅ Supported | Stores emails in memory (for testing) |
|
|
148
|
+
| SES | ✅ Supported | Amazon SES driver |
|
|
149
|
+
| Mailgun | ✅ Supported | Mailgun API driver |
|
|
150
|
+
| SendGrid | ✅ Supported | SendGrid API driver |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 📚 API Reference
|
|
155
|
+
|
|
156
|
+
### `Mail.to(address)`
|
|
157
|
+
|
|
158
|
+
Set the recipient email address.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
Mail.to('user@example.com')
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `subject(text)`
|
|
165
|
+
|
|
166
|
+
Set the email subject.
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
.subject('Welcome')
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### `text(content)`
|
|
173
|
+
|
|
174
|
+
Set plain text email content.
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
.text('Plain text email')
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `view(name, data)`
|
|
181
|
+
|
|
182
|
+
Render an email template.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
.view('emails.reset', { token })
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### `attach(path)`
|
|
189
|
+
|
|
190
|
+
Attach a file from storage.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
.attach('reports/file.pdf')
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### `send(mailable?)`
|
|
197
|
+
|
|
198
|
+
Send the email.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
await Mail.to('user@example.com').send();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
or with a Mailable:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
await Mail.to(user.email).send(new WelcomeMail(user));
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🧠 Architecture
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
mail/
|
|
216
|
+
├── src/
|
|
217
|
+
│ ├── MailManager.ts ← Resolves mailers
|
|
218
|
+
│ ├── Mailer.ts ← Sends messages
|
|
219
|
+
│ ├── Message.ts ← Email message builder
|
|
220
|
+
│ ├── Mailable.ts ← Base class for emails
|
|
221
|
+
│ ├── Transport/
|
|
222
|
+
│ │ └── SmtpTransport.ts
|
|
223
|
+
│ ├── Contracts/
|
|
224
|
+
│ │ └── Transport.ts
|
|
225
|
+
│ └── index.ts
|
|
226
|
+
├── tests/
|
|
227
|
+
│ └── Mail.test.ts
|
|
228
|
+
├── package.json
|
|
229
|
+
├── tsconfig.json
|
|
230
|
+
├── README.md
|
|
231
|
+
└── LICENSE
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 🔌 Extending Mail (Custom Transports)
|
|
237
|
+
|
|
238
|
+
Create a custom transport:
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import { Transport } from '@arikajs/mail';
|
|
242
|
+
|
|
243
|
+
class CustomTransport implements Transport {
|
|
244
|
+
async send(message: any): Promise<void> {
|
|
245
|
+
// Implementation
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Register it with `MailManager`.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🔗 Integration with ArikaJS
|
|
255
|
+
|
|
256
|
+
`@arikajs/mail` integrates with:
|
|
257
|
+
|
|
258
|
+
- **`@arikajs/view`** → Email templates
|
|
259
|
+
- **`@arikajs/storage`** → Attachments
|
|
260
|
+
- **`@arikajs/queue`** → Async email delivery
|
|
261
|
+
- **`@arikajs/config`** → Mailer configuration
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 🧪 Testing
|
|
266
|
+
|
|
267
|
+
Mailables and transports can be mocked for testing.
|
|
268
|
+
A log or array transport will be added for test environments.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 🛣 Roadmap
|
|
273
|
+
|
|
274
|
+
- [ ] Queue-based sending
|
|
275
|
+
- [ ] Markdown email support
|
|
276
|
+
- [ ] Multiple recipients (CC/BCC)
|
|
277
|
+
- [ ] Mail previews
|
|
278
|
+
- [ ] Retry & failure handling
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📄 License
|
|
283
|
+
|
|
284
|
+
`@arikajs/mail` is open-source software licensed under the **MIT License**.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 🧭 Philosophy
|
|
289
|
+
|
|
290
|
+
> "Send emails, not headaches."
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../src/Contracts/Transport.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACtB,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../src/Contracts/Transport.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Mailer, ViewRenderer } from './Mailer';
|
|
2
|
+
export declare class MailManager {
|
|
3
|
+
private config;
|
|
4
|
+
private viewRenderer?;
|
|
5
|
+
private mailers;
|
|
6
|
+
private customCreators;
|
|
7
|
+
constructor(config: any, viewRenderer?: ViewRenderer | undefined);
|
|
8
|
+
extend(driver: string, callback: (config: any) => any): this;
|
|
9
|
+
mailer(name?: string): Mailer;
|
|
10
|
+
protected resolve(name: string): Mailer;
|
|
11
|
+
to(users: any): import("./Mailer").PendingMail;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=MailManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailManager.d.ts","sourceRoot":"","sources":["../src/MailManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKhD,qBAAa,WAAW;IAKR,OAAO,CAAC,MAAM;IAAO,OAAO,CAAC,YAAY,CAAC;IAJtD,OAAO,CAAC,OAAO,CAAkC;IAEjD,OAAO,CAAC,cAAc,CAAgD;gBAElD,MAAM,EAAE,GAAG,EAAU,YAAY,CAAC,EAAE,YAAY,YAAA;IAE7D,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG;IAKrD,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IAUpC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA0ChC,EAAE,CAAC,KAAK,EAAE,GAAG;CAGvB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailManager = void 0;
|
|
4
|
+
const Mailer_1 = require("./Mailer");
|
|
5
|
+
const SmtpTransport_1 = require("./Transport/SmtpTransport");
|
|
6
|
+
const LogTransport_1 = require("./Transport/LogTransport");
|
|
7
|
+
const ArrayTransport_1 = require("./Transport/ArrayTransport");
|
|
8
|
+
class MailManager {
|
|
9
|
+
constructor(config, viewRenderer) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.viewRenderer = viewRenderer;
|
|
12
|
+
this.mailers = new Map();
|
|
13
|
+
this.customCreators = new Map();
|
|
14
|
+
}
|
|
15
|
+
extend(driver, callback) {
|
|
16
|
+
this.customCreators.set(driver, callback);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
mailer(name) {
|
|
20
|
+
const mailerName = name || this.config.default;
|
|
21
|
+
if (!this.mailers.has(mailerName)) {
|
|
22
|
+
this.mailers.set(mailerName, this.resolve(mailerName));
|
|
23
|
+
}
|
|
24
|
+
return this.mailers.get(mailerName);
|
|
25
|
+
}
|
|
26
|
+
resolve(name) {
|
|
27
|
+
const config = this.config.mailers[name];
|
|
28
|
+
if (!config) {
|
|
29
|
+
throw new Error(`Mailer [${name}] is not defined.`);
|
|
30
|
+
}
|
|
31
|
+
let transport;
|
|
32
|
+
if (this.customCreators.has(config.transport)) {
|
|
33
|
+
transport = this.customCreators.get(config.transport)(config);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
switch (config.transport) {
|
|
37
|
+
case 'smtp':
|
|
38
|
+
transport = new SmtpTransport_1.SmtpTransport(config);
|
|
39
|
+
break;
|
|
40
|
+
case 'ses':
|
|
41
|
+
const { SesTransport } = require('./Transport/SesTransport');
|
|
42
|
+
transport = new SesTransport(config);
|
|
43
|
+
break;
|
|
44
|
+
case 'mailgun':
|
|
45
|
+
const { MailgunTransport } = require('./Transport/MailgunTransport');
|
|
46
|
+
transport = new MailgunTransport(config);
|
|
47
|
+
break;
|
|
48
|
+
case 'sendgrid':
|
|
49
|
+
const { SendGridTransport } = require('./Transport/SendGridTransport');
|
|
50
|
+
transport = new SendGridTransport(config);
|
|
51
|
+
break;
|
|
52
|
+
case 'log':
|
|
53
|
+
transport = new LogTransport_1.LogTransport();
|
|
54
|
+
break;
|
|
55
|
+
case 'array':
|
|
56
|
+
transport = new ArrayTransport_1.ArrayTransport();
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported transport driver [${config.transport}].`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new Mailer_1.Mailer(name, transport, this.viewRenderer);
|
|
63
|
+
}
|
|
64
|
+
to(users) {
|
|
65
|
+
return this.mailer().to(users);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.MailManager = MailManager;
|
|
69
|
+
//# sourceMappingURL=MailManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|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|
2
|
+
subjectLine?: string;
|
|
3
|
+
viewPath?: string;
|
|
4
|
+
viewData: any;
|
|
5
|
+
textContent?: string;
|
|
6
|
+
attachments: any[];
|
|
7
|
+
fromAddress?: string | {
|
|
8
|
+
name: string;
|
|
9
|
+
address: string;
|
|
10
|
+
};
|
|
11
|
+
abstract build(): this;
|
|
12
|
+
subject(subject: string): this;
|
|
13
|
+
view(path: string, data?: any): this;
|
|
14
|
+
text(content: string): this;
|
|
15
|
+
attach(path: string): this;
|
|
16
|
+
from(address: string | {
|
|
17
|
+
name: string;
|
|
18
|
+
address: string;
|
|
19
|
+
}): this;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Mailable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mailable.d.ts","sourceRoot":"","sources":["../src/Mailable.ts"],"names":[],"mappings":"AACA,8BAAsB,QAAQ;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAM;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,GAAG,EAAE,CAAM;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAEhE,QAAQ,CAAC,KAAK,IAAI,IAAI;IAEf,OAAO,CAAC,OAAO,EAAE,MAAM;IAKvB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;IAMjC,IAAI,CAAC,OAAO,EAAE,MAAM;IAKpB,MAAM,CAAC,IAAI,EAAE,MAAM;IAKnB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAIlE"}
|
package/dist/Mailable.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mailable = void 0;
|
|
4
|
+
class Mailable {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.viewData = {};
|
|
7
|
+
this.attachments = [];
|
|
8
|
+
}
|
|
9
|
+
subject(subject) {
|
|
10
|
+
this.subjectLine = subject;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
view(path, data = {}) {
|
|
14
|
+
this.viewPath = path;
|
|
15
|
+
this.viewData = data;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
text(content) {
|
|
19
|
+
this.textContent = content;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
attach(path) {
|
|
23
|
+
this.attachments.push({ path });
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
from(address) {
|
|
27
|
+
this.fromAddress = address;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Mailable = Mailable;
|
|
32
|
+
//# sourceMappingURL=Mailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mailable.js","sourceRoot":"","sources":["../src/Mailable.ts"],"names":[],"mappings":";;;AACA,MAAsB,QAAQ;IAA9B;QAGW,aAAQ,GAAQ,EAAE,CAAC;QAEnB,gBAAW,GAAU,EAAE,CAAC;IA8BnC,CAAC;IAzBU,OAAO,CAAC,OAAe;QAC1B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,IAAI,CAAC,IAAY,EAAE,OAAY,EAAE;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,IAAI,CAAC,OAAe;QACvB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,IAAY;QACtB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,IAAI,CAAC,OAAmD;QAC3D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAnCD,4BAmCC"}
|
package/dist/Mailer.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Transport } from './Contracts/Transport';
|
|
2
|
+
import { Mailable } from './Mailable';
|
|
3
|
+
import { Message, Address } from './Message';
|
|
4
|
+
export interface ViewRenderer {
|
|
5
|
+
render(view: string, data: any): Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare class Mailer {
|
|
8
|
+
protected name: string;
|
|
9
|
+
protected transport: Transport;
|
|
10
|
+
protected viewRenderer?: ViewRenderer | undefined;
|
|
11
|
+
constructor(name: string, transport: Transport, viewRenderer?: ViewRenderer | undefined);
|
|
12
|
+
to(users: string | Address | (string | Address)[]): PendingMail;
|
|
13
|
+
send(viewPath: string, data: any, callback: (message: Message) => void): Promise<void>;
|
|
14
|
+
sendMailable(mailable: Mailable): Promise<void>;
|
|
15
|
+
sendRaw(message: any): Promise<void>;
|
|
16
|
+
getRenderer(): ViewRenderer | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare class PendingMail {
|
|
19
|
+
protected mailer: Mailer;
|
|
20
|
+
protected message: Message;
|
|
21
|
+
protected viewPath?: string;
|
|
22
|
+
protected viewData: any;
|
|
23
|
+
constructor(mailer: Mailer);
|
|
24
|
+
to(users: string | Address | (string | Address)[]): this;
|
|
25
|
+
subject(subject: string): this;
|
|
26
|
+
text(content: string): this;
|
|
27
|
+
view(path: string, data?: any): this;
|
|
28
|
+
attach(path: string): this;
|
|
29
|
+
send(mailable?: Mailable): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+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AG,OAAO,CAAC,EAAE;IAKjD,OAAO,CAAC,OAAO,EAAE,MAAM;IAKvB,IAAI,CAAC,OAAO,EAAE,MAAM;IAKpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;IAMjC,MAAM,CAAC,IAAI,EAAE,MAAM;IAKb,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ;CA4BjC"}
|
package/dist/Mailer.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PendingMail = exports.Mailer = void 0;
|
|
4
|
+
const Message_1 = require("./Message");
|
|
5
|
+
class Mailer {
|
|
6
|
+
constructor(name, transport, viewRenderer) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.transport = transport;
|
|
9
|
+
this.viewRenderer = viewRenderer;
|
|
10
|
+
}
|
|
11
|
+
to(users) {
|
|
12
|
+
return new PendingMail(this).to(users);
|
|
13
|
+
}
|
|
14
|
+
async send(viewPath, data, callback) {
|
|
15
|
+
const message = new Message_1.Message();
|
|
16
|
+
callback(message);
|
|
17
|
+
if (viewPath && this.viewRenderer) {
|
|
18
|
+
const html = await this.viewRenderer.render(viewPath, data);
|
|
19
|
+
message.htmlContent(html);
|
|
20
|
+
}
|
|
21
|
+
return this.transport.send(message.getPayload());
|
|
22
|
+
}
|
|
23
|
+
async sendMailable(mailable) {
|
|
24
|
+
return this.sendRaw(mailable);
|
|
25
|
+
}
|
|
26
|
+
async sendRaw(message) {
|
|
27
|
+
return this.transport.send(message);
|
|
28
|
+
}
|
|
29
|
+
getRenderer() {
|
|
30
|
+
return this.viewRenderer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Mailer = Mailer;
|
|
34
|
+
class PendingMail {
|
|
35
|
+
constructor(mailer) {
|
|
36
|
+
this.mailer = mailer;
|
|
37
|
+
this.viewData = {};
|
|
38
|
+
this.message = new Message_1.Message();
|
|
39
|
+
}
|
|
40
|
+
to(users) {
|
|
41
|
+
this.message.to(users);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
subject(subject) {
|
|
45
|
+
this.message.subject(subject);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
text(content) {
|
|
49
|
+
this.message.textContent(content);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
view(path, data = {}) {
|
|
53
|
+
this.viewPath = path;
|
|
54
|
+
this.viewData = data;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
attach(path) {
|
|
58
|
+
this.message.attach({ path });
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
async send(mailable) {
|
|
62
|
+
if (mailable) {
|
|
63
|
+
mailable.build();
|
|
64
|
+
if (mailable.subjectLine)
|
|
65
|
+
this.message.subject(mailable.subjectLine);
|
|
66
|
+
if (mailable.fromAddress)
|
|
67
|
+
this.message.from(mailable.fromAddress);
|
|
68
|
+
if (mailable.textContent)
|
|
69
|
+
this.message.textContent(mailable.textContent);
|
|
70
|
+
if (mailable.viewPath) {
|
|
71
|
+
this.viewPath = mailable.viewPath;
|
|
72
|
+
this.viewData = mailable.viewData;
|
|
73
|
+
}
|
|
74
|
+
if (mailable.attachments) {
|
|
75
|
+
mailable.attachments.forEach(att => this.message.attach(att));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (this.viewPath) {
|
|
79
|
+
const renderer = this.mailer.getRenderer();
|
|
80
|
+
if (renderer) {
|
|
81
|
+
const html = await renderer.render(this.viewPath, this.viewData);
|
|
82
|
+
this.message.htmlContent(html);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return this.mailer.sendRaw(this.message.getPayload());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.PendingMail = PendingMail;
|
|
89
|
+
//# sourceMappingURL=Mailer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AC;gBAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACtC,CAAC;YAED,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACvB,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC3C,IAAI,QAAQ,EAAE,CAAC;gBACX,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,CAAC;CACJ;AA/DD,kCA+DC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface Attachment {
|
|
2
|
+
filename?: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
content?: string | Buffer;
|
|
5
|
+
contentType?: string;
|
|
6
|
+
cid?: string;
|
|
7
|
+
encoding?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Address {
|
|
10
|
+
name: string;
|
|
11
|
+
address: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Message {
|
|
14
|
+
protected _to: (string | Address)[];
|
|
15
|
+
protected _cc: (string | Address)[];
|
|
16
|
+
protected _bcc: (string | Address)[];
|
|
17
|
+
protected _from?: string | Address;
|
|
18
|
+
protected _replyTo?: string | Address;
|
|
19
|
+
protected _subject?: string;
|
|
20
|
+
protected _text?: string;
|
|
21
|
+
protected _html?: string;
|
|
22
|
+
protected _attachments: Attachment[];
|
|
23
|
+
constructor();
|
|
24
|
+
to(address: string | Address | (string | Address)[]): this;
|
|
25
|
+
cc(address: string | Address | (string | Address)[]): this;
|
|
26
|
+
bcc(address: string | Address | (string | Address)[]): this;
|
|
27
|
+
from(address: string | Address): this;
|
|
28
|
+
replyTo(address: string | Address): this;
|
|
29
|
+
subject(subject: string): this;
|
|
30
|
+
textContent(content: string): this;
|
|
31
|
+
htmlContent(content: string): this;
|
|
32
|
+
attach(attachment: Attachment): this;
|
|
33
|
+
getPayload(): {
|
|
34
|
+
to: (string | Address)[];
|
|
35
|
+
cc: (string | Address)[];
|
|
36
|
+
bcc: (string | Address)[];
|
|
37
|
+
from: string | Address | undefined;
|
|
38
|
+
replyTo: string | Address | undefined;
|
|
39
|
+
subject: string | undefined;
|
|
40
|
+
text: string | undefined;
|
|
41
|
+
html: string | undefined;
|
|
42
|
+
attachments: Attachment[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=Message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,OAAO;IAChB,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAM;IACzC,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,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