@h3ravel/mail 8.0.7 → 9.1.0
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/dist/index.cjs +178 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -7
- package/dist/index.d.ts +73 -7
- package/dist/index.js +173 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -31,10 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
LOGDriver: () => LOGDriver,
|
|
34
35
|
MailServiceProvider: () => MailServiceProvider,
|
|
35
36
|
Mailable: () => Mailable,
|
|
36
37
|
Mailer: () => Mailer,
|
|
37
|
-
|
|
38
|
+
SESDriver: () => SESDriver,
|
|
39
|
+
SMTPDriver: () => SMTPDriver,
|
|
40
|
+
SendMailDriver: () => SendMailDriver,
|
|
41
|
+
Service: () => Service
|
|
38
42
|
});
|
|
39
43
|
module.exports = __toCommonJS(src_exports);
|
|
40
44
|
|
|
@@ -125,19 +129,61 @@ var Mailer = class {
|
|
|
125
129
|
if (options.viewPath && !options.html) {
|
|
126
130
|
options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});
|
|
127
131
|
}
|
|
128
|
-
|
|
132
|
+
try {
|
|
133
|
+
return this.driver.send(options);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
129
137
|
}
|
|
130
138
|
};
|
|
131
139
|
|
|
132
|
-
// src/Drivers/
|
|
140
|
+
// src/Drivers/SESDriver.ts
|
|
133
141
|
var import_nodemailer = __toESM(require("nodemailer"), 1);
|
|
142
|
+
var import_client_sesv2 = require("@aws-sdk/client-sesv2");
|
|
143
|
+
var SESDriver = class {
|
|
144
|
+
static {
|
|
145
|
+
__name(this, "SESDriver");
|
|
146
|
+
}
|
|
147
|
+
transporter;
|
|
148
|
+
constructor(config) {
|
|
149
|
+
const sesClient = new import_client_sesv2.SESv2Client({
|
|
150
|
+
region: config.region,
|
|
151
|
+
credentials: {
|
|
152
|
+
accessKeyId: config.key,
|
|
153
|
+
secretAccessKey: config.secret
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
this.transporter = import_nodemailer.default.createTransport({
|
|
157
|
+
SES: {
|
|
158
|
+
sesClient,
|
|
159
|
+
SendEmailCommand: import_client_sesv2.SendEmailCommand
|
|
160
|
+
},
|
|
161
|
+
maxConnections: config.maxConnections,
|
|
162
|
+
sendingRate: config.sendingRate
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async send(options) {
|
|
166
|
+
return await this.transporter.sendMail({
|
|
167
|
+
to: options.to,
|
|
168
|
+
cc: options.cc,
|
|
169
|
+
bcc: options.bcc,
|
|
170
|
+
subject: options.subject,
|
|
171
|
+
html: options.html,
|
|
172
|
+
text: options.text,
|
|
173
|
+
attachments: options.attachments
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/Drivers/SMTPDriver.ts
|
|
179
|
+
var import_nodemailer2 = __toESM(require("nodemailer"), 1);
|
|
134
180
|
var SMTPDriver = class {
|
|
135
181
|
static {
|
|
136
182
|
__name(this, "SMTPDriver");
|
|
137
183
|
}
|
|
138
184
|
transporter;
|
|
139
185
|
constructor(config) {
|
|
140
|
-
this.transporter =
|
|
186
|
+
this.transporter = import_nodemailer2.default.createTransport({
|
|
141
187
|
host: config.host,
|
|
142
188
|
port: config.port,
|
|
143
189
|
secure: config.port === 465,
|
|
@@ -160,29 +206,139 @@ var SMTPDriver = class {
|
|
|
160
206
|
}
|
|
161
207
|
};
|
|
162
208
|
|
|
163
|
-
// src/
|
|
164
|
-
var
|
|
165
|
-
var
|
|
209
|
+
// src/Drivers/LOGDriver.ts
|
|
210
|
+
var import_nodemailer3 = __toESM(require("nodemailer"), 1);
|
|
211
|
+
var import_stream = __toESM(require("stream"), 1);
|
|
212
|
+
var LOGDriver = class {
|
|
166
213
|
static {
|
|
167
|
-
__name(this, "
|
|
214
|
+
__name(this, "LOGDriver");
|
|
168
215
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
216
|
+
transporter;
|
|
217
|
+
constructor(_config) {
|
|
218
|
+
this.transporter = import_nodemailer3.default.createTransport({
|
|
219
|
+
streamTransport: true,
|
|
220
|
+
newline: "unix"
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async send(options) {
|
|
224
|
+
this.transporter.sendMail(options, (err, info) => {
|
|
225
|
+
if (err)
|
|
226
|
+
throw err;
|
|
227
|
+
console.log(info.envelope);
|
|
228
|
+
console.log(info.messageId);
|
|
229
|
+
info.message instanceof import_stream.default.Readable && info.message.pipe(process.stdout);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// src/Drivers/SendMailDriver.ts
|
|
235
|
+
var import_nodemailer4 = __toESM(require("nodemailer"), 1);
|
|
236
|
+
var SendMailDriver = class {
|
|
237
|
+
static {
|
|
238
|
+
__name(this, "SendMailDriver");
|
|
239
|
+
}
|
|
240
|
+
transporter;
|
|
241
|
+
constructor(config) {
|
|
242
|
+
this.transporter = import_nodemailer4.default.createTransport({
|
|
243
|
+
sendmail: true,
|
|
244
|
+
path: config.path
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async send(options) {
|
|
248
|
+
return await this.transporter.sendMail({
|
|
249
|
+
to: options.to,
|
|
250
|
+
cc: options.cc,
|
|
251
|
+
bcc: options.bcc,
|
|
252
|
+
subject: options.subject,
|
|
253
|
+
html: options.html,
|
|
254
|
+
text: options.text,
|
|
255
|
+
attachments: options.attachments
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/Service.ts
|
|
261
|
+
var Service = class {
|
|
262
|
+
static {
|
|
263
|
+
__name(this, "Service");
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Initializes the mailer service with the given application instance
|
|
267
|
+
*
|
|
268
|
+
* @param app
|
|
269
|
+
* @returns
|
|
270
|
+
*/
|
|
271
|
+
static init(app) {
|
|
272
|
+
const view = app.make("view");
|
|
273
|
+
const config = app.make("config");
|
|
274
|
+
const mailConfig = {
|
|
275
|
+
/**
|
|
276
|
+
* SMTP configuration with fallback defaults
|
|
277
|
+
*/
|
|
278
|
+
smtp: {
|
|
175
279
|
host: config.get("mail.mailers.smtp.host", "smtp.mailtrap.io"),
|
|
176
280
|
port: Number(config.get("mail.mailers.smtp.port", 2525)),
|
|
177
281
|
auth: {
|
|
178
282
|
user: config.get("mail.mailers.smtp.username", ""),
|
|
179
283
|
pass: config.get("mail.mailers.smtp.password", "")
|
|
180
284
|
},
|
|
181
|
-
opportunisticTLS: config.get("mail.
|
|
285
|
+
opportunisticTLS: config.get("mail.mail\u6C14\u7684mailers.smtp.encryption") === "tls",
|
|
182
286
|
connectionTimeout: config.get("mail.mailers.smtp.timeout"),
|
|
183
287
|
debug: false
|
|
184
|
-
}
|
|
185
|
-
|
|
288
|
+
},
|
|
289
|
+
/**
|
|
290
|
+
* SES configuration with fallback defaults
|
|
291
|
+
*/
|
|
292
|
+
ses: {
|
|
293
|
+
key: config.get("services.ses.key", ""),
|
|
294
|
+
secret: config.get("services.ses.secret", ""),
|
|
295
|
+
region: config.get("services.ses.region", "us-east-1"),
|
|
296
|
+
maxConnections: config.get("mail.mailers.ses.connections", 10),
|
|
297
|
+
sendingRate: config.get("mail.mailers.ses.rate", 5)
|
|
298
|
+
},
|
|
299
|
+
/**
|
|
300
|
+
* Sendmail configuration with fallback default path
|
|
301
|
+
*/
|
|
302
|
+
sendmail: {
|
|
303
|
+
path: config.get("mail.mailers.sendmail.path", "sendmail")
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const driver = {
|
|
307
|
+
/**
|
|
308
|
+
* SES driver factory
|
|
309
|
+
* @returns
|
|
310
|
+
*/
|
|
311
|
+
ses: () => new SESDriver(mailConfig.ses),
|
|
312
|
+
/**
|
|
313
|
+
* SMTP driver factory
|
|
314
|
+
* @returns
|
|
315
|
+
*/
|
|
316
|
+
smtp: () => new SMTPDriver(mailConfig.smtp),
|
|
317
|
+
/**
|
|
318
|
+
* LOG driver factory for debugging
|
|
319
|
+
* @returns
|
|
320
|
+
*/
|
|
321
|
+
log: () => new LOGDriver(mailConfig.smtp),
|
|
322
|
+
/**
|
|
323
|
+
* Sendmail driver factory
|
|
324
|
+
* @returns
|
|
325
|
+
*/
|
|
326
|
+
sendmail: () => new SendMailDriver(mailConfig.sendmail)
|
|
327
|
+
};
|
|
328
|
+
return new Mailer((driver[config.get("mail.default")] ?? driver.smtp)(), async (viewPath, data) => await view(viewPath, data));
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// src/Providers/MailServiceProvider.ts
|
|
333
|
+
var import_core = require("@h3ravel/core");
|
|
334
|
+
var MailServiceProvider = class extends import_core.ServiceProvider {
|
|
335
|
+
static {
|
|
336
|
+
__name(this, "MailServiceProvider");
|
|
337
|
+
}
|
|
338
|
+
static priority = 990;
|
|
339
|
+
register() {
|
|
340
|
+
this.app.singleton(Mailer, () => {
|
|
341
|
+
return Service.init(this.app);
|
|
186
342
|
});
|
|
187
343
|
}
|
|
188
344
|
boot() {
|
|
@@ -190,9 +346,13 @@ var MailServiceProvider = class extends import_core.ServiceProvider {
|
|
|
190
346
|
};
|
|
191
347
|
// Annotate the CommonJS export names for ESM import in node:
|
|
192
348
|
0 && (module.exports = {
|
|
349
|
+
LOGDriver,
|
|
193
350
|
MailServiceProvider,
|
|
194
351
|
Mailable,
|
|
195
352
|
Mailer,
|
|
196
|
-
|
|
353
|
+
SESDriver,
|
|
354
|
+
SMTPDriver,
|
|
355
|
+
SendMailDriver,
|
|
356
|
+
Service
|
|
197
357
|
});
|
|
198
358
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Mailable.ts","../src/Mailer.ts","../src/Drivers/SMTPDriver.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Helpers';\nexport * from './Mailable';\nexport * from './Mailer';\nexport * from './Contracts/Mailer';\nexport * from './Drivers/SES';\nexport * from './Drivers/SMTPDriver';\nexport * from './Providers/MailServiceProvider';\n","import type { SendMailOptions } from \"./Contracts/Mailer\";\n\nexport abstract class Mailable {\n protected toAddress?: string;\n protected ccAddresses?: string[];\n protected bccAddresses?: string[];\n protected subjectText?: string;\n protected htmlContent?: string;\n protected textContent?: string;\n protected viewPath?: string;\n protected viewData?: Record<string, any>;\n protected attachmentsList?: SendMailOptions['attachments'];\n\n to (address: string) {\n this.toAddress = address;\n return this;\n }\n\n cc (...addresses: string[]) {\n this.ccAddresses = addresses;\n return this;\n }\n\n bcc (...addresses: string[]) {\n this.bccAddresses = addresses;\n return this;\n }\n\n subject (subject: string) {\n this.subjectText = subject;\n return this;\n }\n\n html (html: string) {\n this.htmlContent = html;\n return this;\n }\n\n text (text: string) {\n this.textContent = text;\n return this;\n }\n\n view (path: string, data: Record<string, any> = {}) {\n this.viewPath = path;\n this.viewData = data;\n return this;\n }\n\n attach (filename: string, filePath: string) {\n if (!this.attachmentsList) this.attachmentsList = [];\n this.attachmentsList.push({ filename, path: filePath });\n return this;\n }\n\n /**\n * Child classes should define build() like in Laravel\n */\n abstract build (): Promise<this> | this;\n\n /**\n * Called internally by Mailer\n */\n getMessageOptions (): SendMailOptions {\n return {\n to: this.toAddress,\n cc: this.ccAddresses,\n bcc: this.bccAddresses,\n subject: this.subjectText,\n html: this.htmlContent,\n text: this.textContent,\n viewPath: this.viewPath,\n viewData: this.viewData,\n attachments: this.attachmentsList\n };\n }\n}\n","import { MailDriverContract } from './Contracts/Mailer';\nimport { Mailable } from './Mailable';\n\nexport class Mailer {\n constructor(\n private driver: MailDriverContract,\n private edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>\n ) { }\n\n async send (mailable: Mailable) {\n await mailable.build();\n\n const options = mailable.getMessageOptions();\n\n if (options.viewPath && !options.html) {\n options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});\n }\n\n return this.driver.send(options);\n }\n}\n","import nodemailer, { type SendMailOptions, type TransportOptions } from 'nodemailer';\n\nimport { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';\n\nexport class SMTPDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SMTPConfig) {\n this.transporter = nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.port === 465, // auto decide based on port\n auth: {\n user: config.auth.user,\n pass: config.auth.pass\n }\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import { Mailer } from '../Mailer';\nimport { SMTPConfig } from '../Contracts/Mailer';\nimport { SMTPDriver } from '../Drivers/SMTPDriver';\nimport { ServiceProvider } from '@h3ravel/core';\n\n/**\n * Mail delivery setup.\n * \n * Bind Mailer service.\n * Load mail drivers (SMTP, SES, etc.).\n * Register Mail facade.\n * \n */\nexport class MailServiceProvider extends ServiceProvider {\n public static priority = 990;\n register () {\n /**\n * Register Mailer instance\n */\n\n this.app.singleton<any>('mailer', () => {\n // this.app.bind(Mailer, () => {\n const view = this.app.make('view');\n const config = this.app.make('config');\n\n const smtpConfig: SMTPConfig = {\n host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),\n port: Number(config.get('mail.mailers.smtp.port', 2525)),\n auth: {\n user: config.get('mail.mailers.smtp.username', ''),\n pass: config.get('mail.mailers.smtp.password', ''),\n },\n opportunisticTLS: config.get('mail.mailers.smtp.encryption') === 'tls',\n connectionTimeout: config.get('mail.mailers.smtp.timeout'),\n debug: false,\n };\n\n return new Mailer(\n new SMTPDriver(smtpConfig),\n async (viewPath, data) => await view(viewPath, data)\n );\n });\n }\n\n boot () {\n /**\n * Add logic here for global mail \"from\" address and others\n */\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACEO,IAAeA,WAAf,MAAeA;EAAtB,OAAsBA;;;EACRC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEVC,GAAIC,SAAiB;AACjB,SAAKV,YAAYU;AACjB,WAAO;EACX;EAEAC,MAAOC,WAAqB;AACxB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,OAAQD,WAAqB;AACzB,SAAKV,eAAeU;AACpB,WAAO;EACX;EAEAE,QAASA,SAAiB;AACtB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMC,MAAcC,OAA4B,CAAC,GAAG;AAChD,SAAKb,WAAWY;AAChB,SAAKX,WAAWY;AAChB,WAAO;EACX;EAEAC,OAAQC,UAAkBC,UAAkB;AACxC,QAAI,CAAC,KAAKd;AAAiB,WAAKA,kBAAkB,CAAA;AAClD,SAAKA,gBAAgBe,KAAK;MAAEF;MAAUH,MAAMI;IAAS,CAAA;AACrD,WAAO;EACX;;;;EAUAE,oBAAsC;AAClC,WAAO;MACHf,IAAI,KAAKT;MACTW,IAAI,KAAKV;MACTY,KAAK,KAAKX;MACVY,SAAS,KAAKX;MACdY,MAAM,KAAKX;MACXY,MAAM,KAAKX;MACXC,UAAU,KAAKA;MACfC,UAAU,KAAKA;MACfkB,aAAa,KAAKjB;IACtB;EACJ;AACJ;;;ACzEO,IAAMkB,SAAN,MAAMA;EAAb,OAAaA;;;;;E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,MAAM;UACFC,MAAMP,OAAOG,IAAI,8BAA8B,EAAA;UAC/CK,MAAMR,OAAOG,IAAI,8BAA8B,EAAA;QACnD;QACAM,kBAAkBT,OAAOG,IAAI,8BAAA,MAAoC;QACjEO,mBAAmBV,OAAOG,IAAI,2BAAA;QAC9BQ,OAAO;MACX;AAEA,aAAO,IAAIC,OACP,IAAIC,WAAWZ,UAAAA,GACf,OAAOa,UAAUC,SAAS,MAAMjB,KAAKgB,UAAUC,IAAAA,CAAAA;IAEvD,CAAA;EACJ;EAEAC,OAAQ;EAIR;AACJ;","names":["Mailable","toAddress","ccAddresses","bccAddresses","subjectText","htmlContent","textContent","viewPath","viewData","attachmentsList","to","address","cc","addresses","bcc","subject","html","text","view","path","data","attach","filename","filePath","push","getMessageOptions","attachments","Mailer","driver","edgeRenderer","send","mailable","build","options","getMessageOptions","viewPath","html","viewData","SMTPDriver","transporter","config","nodemailer","createTransport","host","port","secure","auth","user","pass","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","MailServiceProvider","ServiceProvider","priority","register","app","singleton","view","make","config","smtpConfig","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","Mailer","SMTPDriver","viewPath","data","boot"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Mailable.ts","../src/Mailer.ts","../src/Drivers/SESDriver.ts","../src/Drivers/SMTPDriver.ts","../src/Drivers/LOGDriver.ts","../src/Drivers/SendMailDriver.ts","../src/Service.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Helpers';\nexport * from './Mailable';\nexport * from './Mailer';\nexport * from './Service';\nexport * from './Contracts/Mailer';\nexport * from './Drivers/LOGDriver';\nexport * from './Drivers/SESDriver';\nexport * from './Drivers/SMTPDriver';\nexport * from './Drivers/SendMailDriver';\nexport * from './Providers/MailServiceProvider';\n","import type { SendMailOptions } from \"./Contracts/Mailer\";\n\nexport abstract class Mailable {\n protected toAddress?: string;\n protected ccAddresses?: string[];\n protected bccAddresses?: string[];\n protected subjectText?: string;\n protected htmlContent?: string;\n protected textContent?: string;\n protected viewPath?: string;\n protected viewData?: Record<string, any>;\n protected attachmentsList?: SendMailOptions['attachments'];\n\n to (address: string) {\n this.toAddress = address;\n return this;\n }\n\n cc (...addresses: string[]) {\n this.ccAddresses = addresses;\n return this;\n }\n\n bcc (...addresses: string[]) {\n this.bccAddresses = addresses;\n return this;\n }\n\n subject (subject: string) {\n this.subjectText = subject;\n return this;\n }\n\n html (html: string) {\n this.htmlContent = html;\n return this;\n }\n\n text (text: string) {\n this.textContent = text;\n return this;\n }\n\n view (path: string, data: Record<string, any> = {}) {\n this.viewPath = path;\n this.viewData = data;\n return this;\n }\n\n attach (filename: string, filePath: string) {\n if (!this.attachmentsList) this.attachmentsList = [];\n this.attachmentsList.push({ filename, path: filePath });\n return this;\n }\n\n /**\n * Child classes should define build() like in Laravel\n */\n abstract build (): Promise<this> | this;\n\n /**\n * Called internally by Mailer\n */\n getMessageOptions (): SendMailOptions {\n return {\n to: this.toAddress,\n cc: this.ccAddresses,\n bcc: this.bccAddresses,\n subject: this.subjectText,\n html: this.htmlContent,\n text: this.textContent,\n viewPath: this.viewPath,\n viewData: this.viewData,\n attachments: this.attachmentsList\n };\n }\n}\n","import { DeliveryReport, MailDriverContract } from './Contracts/Mailer';\n\nimport { Mailable } from './Mailable';\n\nexport class Mailer {\n constructor(\n private driver: MailDriverContract,\n private edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>\n ) { }\n\n async send (mailable: Mailable): Promise<DeliveryReport | undefined | void> {\n await mailable.build();\n\n const options = mailable.getMessageOptions();\n\n if (options.viewPath && !options.html) {\n options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});\n }\n\n try {\n return this.driver.send(options);\n } catch (error) {\n return\n }\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SESConfig } from '../Contracts/Mailer';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport class SESDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SESConfig) {\n\n // 1. Configure the AWS SDK client (uses default credential chain if omitted)\n const sesClient = new SESv2Client({\n region: config.region,\n credentials: {\n accessKeyId: config.key,\n secretAccessKey: config.secret\n }\n });\n\n // 2. Create a Nodemailer transport that points at SES\n this.transporter = nodemailer.createTransport({\n SES: { sesClient, SendEmailCommand },\n maxConnections: config.maxConnections,\n sendingRate: config.sendingRate\n });\n }\n\n async send (options: SendMailOptions) {\n // 3. Send the message\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';\n\nexport class SMTPDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SMTPConfig) {\n this.transporter = nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.port === 465, // auto decide based on port\n auth: {\n user: config.auth.user,\n pass: config.auth.pass\n }\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract } from '../Contracts/Mailer';\nimport Stream from 'stream';\n\nexport class LOGDriver implements MailDriverContract {\n private transporter\n\n constructor(_config: any) {\n this.transporter = nodemailer.createTransport({\n streamTransport: true,\n newline: \"unix\",\n });\n }\n\n async send (options: SendMailOptions) {\n this.transporter.sendMail(options, (err, info) => {\n if (err) throw err;\n console.log(info.envelope);\n console.log(info.messageId);\n // Pipe the raw RFC 822 message to STDOUT\n info.message instanceof Stream.Readable && info.message.pipe(process.stdout);\n }\n );\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SendMailConfig } from '../Contracts/Mailer';\n\nexport class SendMailDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SendMailConfig) {\n this.transporter = nodemailer.createTransport({\n sendmail: true,\n path: config.path,\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import { Application } from \"@h3ravel/core\";\nimport { SendMailConfig, SESConfig, SMTPConfig } from \"./Contracts/Mailer\";\nimport { SESDriver } from \"./Drivers/SESDriver\";\nimport { SMTPDriver } from \"./Drivers/SMTPDriver\";\nimport { LOGDriver } from \"./Drivers/LOGDriver\";\nimport { SendMailDriver } from \"./Drivers/SendMailDriver\";\nimport { Mailer } from \"./Mailer\";\n\n/**\n * Service class to initialize and configure the mailer service\n */\nexport class Service {\n /**\n * Initializes the mailer service with the given application instance\n * \n * @param app \n * @returns \n */\n static init (app: Application) {\n /**\n * Resolve the view and config services from the container\n */\n const view = app.make('view');\n const config = app.make('config');\n\n /**\n * Configure mailer settings for different drivers\n */\n const mailConfig = {\n /**\n * SMTP configuration with fallback defaults\n */\n smtp: <SMTPConfig>{\n host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),\n port: Number(config.get('mail.mailers.smtp.port', 2525)),\n auth: {\n user: config.get('mail.mailers.smtp.username', ''),\n pass: config.get('mail.mailers.smtp.password', ''),\n },\n opportunisticTLS: config.get('mail.mail气的mailers.smtp.encryption') === 'tls',\n connectionTimeout: config.get('mail.mailers.smtp.timeout'),\n debug: false,\n },\n /**\n * SES configuration with fallback defaults\n */\n ses: <SESConfig>{\n key: config.get('services.ses.key', ''),\n secret: config.get('services.ses.secret', ''),\n region: config.get('services.ses.region', 'us-east-1'),\n maxConnections: config.get('mail.mailers.ses.connections', 10),\n sendingRate: config.get('mail.mailers.ses.rate', 5),\n },\n /**\n * Sendmail configuration with fallback default path\n */\n sendmail: <SendMailConfig>{\n path: config.get('mail.mailers.sendmail.path', 'sendmail'),\n },\n };\n\n /**\n * Define available mail drivers\n */\n const driver = {\n /**\n * SES driver factory\n * @returns \n */\n ses: () => new SESDriver(mailConfig.ses),\n /**\n * SMTP driver factory\n * @returns \n */\n smtp: () => new SMTPDriver(mailConfig.smtp),\n /**\n * LOG driver factory for debugging\n * @returns \n */\n log: () => new LOGDriver(mailConfig.smtp),\n /**\n * Sendmail driver factory\n * @returns \n */\n sendmail: () => new SendMailDriver(mailConfig.sendmail),\n };\n\n /**\n * Initialize Mailer with the selected driver (default to SMTP if not specified)\n * and a view rendering function\n */\n return new Mailer(\n (driver[config.get('mail.default') as keyof typeof driver] ?? driver.smtp)(),\n async (viewPath, data) => await view(viewPath, data)\n );\n }\n}\n","import { SESConfig, SMTPConfig, SendMailConfig } from '../Contracts/Mailer';\n\nimport { LOGDriver } from '../Drivers/LOGDriver';\nimport { Mailer } from '../Mailer';\nimport { SESDriver } from '../Drivers/SESDriver';\nimport { SMTPDriver } from '../Drivers/SMTPDriver';\nimport { SendMailDriver } from '../Drivers/SendMailDriver';\nimport { Service } from '../Service';\nimport { ServiceProvider } from '@h3ravel/core';\n\n/**\n * Mail delivery setup.\n * \n * Bind Mailer service.\n * Load mail drivers (SMTP, SES, etc.).\n * Register Mail facade.\n * \n */\nexport class MailServiceProvider extends ServiceProvider {\n public static priority = 990;\n register () {\n /**\n * Register Mailer instance\n */\n this.app.singleton<any>(Mailer, () => {\n return Service.init(this.app)\n });\n }\n\n boot () {\n /**\n * Add logic here for global mail \"from\" address and others\n */\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;ACEO,IAAeA,WAAf,MAAeA;EAAtB,OAAsBA;;;EACRC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEVC,GAAIC,SAAiB;AACjB,SAAKV,YAAYU;AACjB,WAAO;EACX;E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I,8CAAA,MAA0C;QACvEO,mBAAmBX,OAAOI,IAAI,2BAAA;QAC9BQ,OAAO;MACX;;;;MAIAC,KAAgB;QACZC,KAAKd,OAAOI,IAAI,oBAAoB,EAAA;QACpCW,QAAQf,OAAOI,IAAI,uBAAuB,EAAA;QAC1CY,QAAQhB,OAAOI,IAAI,uBAAuB,WAAA;QAC1Ca,gBAAgBjB,OAAOI,IAAI,gCAAgC,EAAA;QAC3Dc,aAAalB,OAAOI,IAAI,yBAAyB,CAAA;MACrD;;;;MAIAe,UAA0B;QACtBC,MAAMpB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMiB,SAAS;;;;;MAKXR,KAAK,MAAM,IAAIS,UAAUrB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAIqB,WAAWtB,WAAWC,IAAI;;;;;MAK1CsB,KAAK,MAAM,IAAIC,UAAUxB,WAAWC,IAAI;;;;;MAKxCiB,UAAU,MAAM,IAAIO,eAAezB,WAAWkB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOrB,OAAOI,IAAI,cAAA,CAAA,KAA2CiB,OAAOnB,MAAG,GACxE,OAAO0B,UAAUC,SAAS,MAAM/B,KAAK8B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACxFA,kBAAgC;AAUzB,IAAMC,sBAAN,cAAkCC,4BAAAA;EAfzC,OAeyCA;;;EACrC,OAAcC,WAAW;EACzBC,WAAY;AAIR,SAAKC,IAAIC,UAAeC,QAAQ,MAAA;AAC5B,aAAOC,QAAQC,KAAK,KAAKJ,GAAG;IAChC,CAAA;EACJ;EAEAK,OAAQ;EAIR;AACJ;","names":["Mailable","toAddress","ccAddresses","bccAddresses","subjectText","htmlContent","textContent","viewPath","viewData","attachmentsList","to","address","cc","addresses","bcc","subject","html","text","view","path","data","attach","filename","filePath","push","getMessageOptions","attachments","Mailer","driver","edgeRenderer","send","mailable","build","options","getMessageOptions","viewPath","html","viewData","error","SESDriver","transporter","config","sesClient","SESv2Client","region","credentials","accessKeyId","key","secretAccessKey","secret","nodemailer","createTransport","SES","SendEmailCommand","maxConnections","sendingRate","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","import_nodemailer","SMTPDriver","transporter","config","nodemailer","createTransport","host","port","secure","auth","user","pass","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","import_nodemailer","LOGDriver","transporter","_config","nodemailer","createTransport","streamTransport","newline","send","options","sendMail","err","info","console","log","envelope","messageId","message","Stream","Readable","pipe","process","stdout","import_nodemailer","SendMailDriver","transporter","config","nodemailer","createTransport","sendmail","path","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","Service","init","app","view","make","config","mailConfig","smtp","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","ses","key","secret","region","maxConnections","sendingRate","sendmail","path","driver","SESDriver","SMTPDriver","log","LOGDriver","SendMailDriver","Mailer","viewPath","data","MailServiceProvider","ServiceProvider","priority","register","app","singleton","Mailer","Service","init","boot"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,22 +1,57 @@
|
|
|
1
|
-
import { SendMailOptions as SendMailOptions$1 } from 'nodemailer';
|
|
1
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from 'nodemailer';
|
|
2
|
+
import * as SESConnection from 'nodemailer/lib/ses-transport';
|
|
3
|
+
import SESConnection__default from 'nodemailer/lib/ses-transport';
|
|
2
4
|
import SMTPConnection from 'nodemailer/lib/smtp-connection';
|
|
5
|
+
import * as SendmailTransport from 'nodemailer/lib/sendmail-transport';
|
|
6
|
+
import SendmailTransport__default from 'nodemailer/lib/sendmail-transport';
|
|
7
|
+
import { Application, ServiceProvider } from '@h3ravel/core';
|
|
3
8
|
import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
|
|
4
|
-
import { ServiceProvider } from '@h3ravel/core';
|
|
5
9
|
|
|
10
|
+
interface DeliveryReport {
|
|
11
|
+
accepted: string[];
|
|
12
|
+
rejected: string[];
|
|
13
|
+
ehlo: string[];
|
|
14
|
+
envelopeTime: number;
|
|
15
|
+
messageTime: number;
|
|
16
|
+
messageSize: number;
|
|
17
|
+
response: string;
|
|
18
|
+
envelope: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
to: string[];
|
|
21
|
+
from: string;
|
|
22
|
+
};
|
|
23
|
+
messageId: string;
|
|
24
|
+
}
|
|
6
25
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
7
26
|
viewPath?: string;
|
|
8
27
|
viewData?: Record<string, any>;
|
|
9
28
|
}
|
|
10
29
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
31
|
+
host?: string | undefined;
|
|
32
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
33
|
+
port?: number | undefined;
|
|
34
|
+
/** defines authentication data */
|
|
13
35
|
auth: {
|
|
14
36
|
user: string;
|
|
15
37
|
pass: string;
|
|
16
38
|
};
|
|
17
39
|
}
|
|
40
|
+
interface SESConfig extends SESConnection__default.Options {
|
|
41
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
42
|
+
maxConnections?: number | undefined;
|
|
43
|
+
/** How many parallel connections to allow towards SES */
|
|
44
|
+
sendingRate?: number | undefined;
|
|
45
|
+
region?: string;
|
|
46
|
+
secret: string;
|
|
47
|
+
key: string;
|
|
48
|
+
}
|
|
49
|
+
interface SendMailConfig extends SendmailTransport__default.Options {
|
|
50
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
51
|
+
path?: string | undefined;
|
|
52
|
+
}
|
|
18
53
|
interface MailDriverContract {
|
|
19
|
-
send(options: SendMailOptions$1): Promise<
|
|
54
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
20
55
|
}
|
|
21
56
|
|
|
22
57
|
declare abstract class Mailable {
|
|
@@ -51,7 +86,32 @@ declare class Mailer {
|
|
|
51
86
|
private driver;
|
|
52
87
|
private edgeRenderer;
|
|
53
88
|
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
54
|
-
send(mailable: Mailable): Promise<
|
|
89
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Service class to initialize and configure the mailer service
|
|
94
|
+
*/
|
|
95
|
+
declare class Service {
|
|
96
|
+
/**
|
|
97
|
+
* Initializes the mailer service with the given application instance
|
|
98
|
+
*
|
|
99
|
+
* @param app
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
static init(app: Application): Mailer;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare class LOGDriver implements MailDriverContract {
|
|
106
|
+
private transporter;
|
|
107
|
+
constructor(_config: any);
|
|
108
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare class SESDriver implements MailDriverContract {
|
|
112
|
+
private transporter;
|
|
113
|
+
constructor(config: SESConfig);
|
|
114
|
+
send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
|
|
55
115
|
}
|
|
56
116
|
|
|
57
117
|
declare class SMTPDriver implements MailDriverContract {
|
|
@@ -60,6 +120,12 @@ declare class SMTPDriver implements MailDriverContract {
|
|
|
60
120
|
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
|
|
61
121
|
}
|
|
62
122
|
|
|
123
|
+
declare class SendMailDriver implements MailDriverContract {
|
|
124
|
+
private transporter;
|
|
125
|
+
constructor(config: SendMailConfig);
|
|
126
|
+
send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
|
|
127
|
+
}
|
|
128
|
+
|
|
63
129
|
/**
|
|
64
130
|
* Mail delivery setup.
|
|
65
131
|
*
|
|
@@ -74,4 +140,4 @@ declare class MailServiceProvider extends ServiceProvider {
|
|
|
74
140
|
boot(): void;
|
|
75
141
|
}
|
|
76
142
|
|
|
77
|
-
export { type MailDriverContract, MailServiceProvider, Mailable, Mailer, type SMTPConfig, SMTPDriver, type SendMailOptions };
|
|
143
|
+
export { type DeliveryReport, LOGDriver, type MailDriverContract, MailServiceProvider, Mailable, Mailer, type SESConfig, SESDriver, type SMTPConfig, SMTPDriver, type SendMailConfig, SendMailDriver, type SendMailOptions, Service };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,57 @@
|
|
|
1
|
-
import { SendMailOptions as SendMailOptions$1 } from 'nodemailer';
|
|
1
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from 'nodemailer';
|
|
2
|
+
import * as SESConnection from 'nodemailer/lib/ses-transport';
|
|
3
|
+
import SESConnection__default from 'nodemailer/lib/ses-transport';
|
|
2
4
|
import SMTPConnection from 'nodemailer/lib/smtp-connection';
|
|
5
|
+
import * as SendmailTransport from 'nodemailer/lib/sendmail-transport';
|
|
6
|
+
import SendmailTransport__default from 'nodemailer/lib/sendmail-transport';
|
|
7
|
+
import { Application, ServiceProvider } from '@h3ravel/core';
|
|
3
8
|
import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
|
|
4
|
-
import { ServiceProvider } from '@h3ravel/core';
|
|
5
9
|
|
|
10
|
+
interface DeliveryReport {
|
|
11
|
+
accepted: string[];
|
|
12
|
+
rejected: string[];
|
|
13
|
+
ehlo: string[];
|
|
14
|
+
envelopeTime: number;
|
|
15
|
+
messageTime: number;
|
|
16
|
+
messageSize: number;
|
|
17
|
+
response: string;
|
|
18
|
+
envelope: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
to: string[];
|
|
21
|
+
from: string;
|
|
22
|
+
};
|
|
23
|
+
messageId: string;
|
|
24
|
+
}
|
|
6
25
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
7
26
|
viewPath?: string;
|
|
8
27
|
viewData?: Record<string, any>;
|
|
9
28
|
}
|
|
10
29
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
11
|
-
|
|
12
|
-
|
|
30
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
31
|
+
host?: string | undefined;
|
|
32
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
33
|
+
port?: number | undefined;
|
|
34
|
+
/** defines authentication data */
|
|
13
35
|
auth: {
|
|
14
36
|
user: string;
|
|
15
37
|
pass: string;
|
|
16
38
|
};
|
|
17
39
|
}
|
|
40
|
+
interface SESConfig extends SESConnection__default.Options {
|
|
41
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
42
|
+
maxConnections?: number | undefined;
|
|
43
|
+
/** How many parallel connections to allow towards SES */
|
|
44
|
+
sendingRate?: number | undefined;
|
|
45
|
+
region?: string;
|
|
46
|
+
secret: string;
|
|
47
|
+
key: string;
|
|
48
|
+
}
|
|
49
|
+
interface SendMailConfig extends SendmailTransport__default.Options {
|
|
50
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
51
|
+
path?: string | undefined;
|
|
52
|
+
}
|
|
18
53
|
interface MailDriverContract {
|
|
19
|
-
send(options: SendMailOptions$1): Promise<
|
|
54
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
20
55
|
}
|
|
21
56
|
|
|
22
57
|
declare abstract class Mailable {
|
|
@@ -51,7 +86,32 @@ declare class Mailer {
|
|
|
51
86
|
private driver;
|
|
52
87
|
private edgeRenderer;
|
|
53
88
|
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
54
|
-
send(mailable: Mailable): Promise<
|
|
89
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Service class to initialize and configure the mailer service
|
|
94
|
+
*/
|
|
95
|
+
declare class Service {
|
|
96
|
+
/**
|
|
97
|
+
* Initializes the mailer service with the given application instance
|
|
98
|
+
*
|
|
99
|
+
* @param app
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
static init(app: Application): Mailer;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare class LOGDriver implements MailDriverContract {
|
|
106
|
+
private transporter;
|
|
107
|
+
constructor(_config: any);
|
|
108
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare class SESDriver implements MailDriverContract {
|
|
112
|
+
private transporter;
|
|
113
|
+
constructor(config: SESConfig);
|
|
114
|
+
send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
|
|
55
115
|
}
|
|
56
116
|
|
|
57
117
|
declare class SMTPDriver implements MailDriverContract {
|
|
@@ -60,6 +120,12 @@ declare class SMTPDriver implements MailDriverContract {
|
|
|
60
120
|
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
|
|
61
121
|
}
|
|
62
122
|
|
|
123
|
+
declare class SendMailDriver implements MailDriverContract {
|
|
124
|
+
private transporter;
|
|
125
|
+
constructor(config: SendMailConfig);
|
|
126
|
+
send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
|
|
127
|
+
}
|
|
128
|
+
|
|
63
129
|
/**
|
|
64
130
|
* Mail delivery setup.
|
|
65
131
|
*
|
|
@@ -74,4 +140,4 @@ declare class MailServiceProvider extends ServiceProvider {
|
|
|
74
140
|
boot(): void;
|
|
75
141
|
}
|
|
76
142
|
|
|
77
|
-
export { type MailDriverContract, MailServiceProvider, Mailable, Mailer, type SMTPConfig, SMTPDriver, type SendMailOptions };
|
|
143
|
+
export { type DeliveryReport, LOGDriver, type MailDriverContract, MailServiceProvider, Mailable, Mailer, type SESConfig, SESDriver, type SMTPConfig, SMTPDriver, type SendMailConfig, SendMailDriver, type SendMailOptions, Service };
|
package/dist/index.js
CHANGED
|
@@ -88,19 +88,61 @@ var Mailer = class {
|
|
|
88
88
|
if (options.viewPath && !options.html) {
|
|
89
89
|
options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
try {
|
|
92
|
+
return this.driver.send(options);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
|
|
95
|
-
// src/Drivers/
|
|
99
|
+
// src/Drivers/SESDriver.ts
|
|
96
100
|
import nodemailer from "nodemailer";
|
|
101
|
+
import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
|
|
102
|
+
var SESDriver = class {
|
|
103
|
+
static {
|
|
104
|
+
__name(this, "SESDriver");
|
|
105
|
+
}
|
|
106
|
+
transporter;
|
|
107
|
+
constructor(config) {
|
|
108
|
+
const sesClient = new SESv2Client({
|
|
109
|
+
region: config.region,
|
|
110
|
+
credentials: {
|
|
111
|
+
accessKeyId: config.key,
|
|
112
|
+
secretAccessKey: config.secret
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
this.transporter = nodemailer.createTransport({
|
|
116
|
+
SES: {
|
|
117
|
+
sesClient,
|
|
118
|
+
SendEmailCommand
|
|
119
|
+
},
|
|
120
|
+
maxConnections: config.maxConnections,
|
|
121
|
+
sendingRate: config.sendingRate
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async send(options) {
|
|
125
|
+
return await this.transporter.sendMail({
|
|
126
|
+
to: options.to,
|
|
127
|
+
cc: options.cc,
|
|
128
|
+
bcc: options.bcc,
|
|
129
|
+
subject: options.subject,
|
|
130
|
+
html: options.html,
|
|
131
|
+
text: options.text,
|
|
132
|
+
attachments: options.attachments
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// src/Drivers/SMTPDriver.ts
|
|
138
|
+
import nodemailer2 from "nodemailer";
|
|
97
139
|
var SMTPDriver = class {
|
|
98
140
|
static {
|
|
99
141
|
__name(this, "SMTPDriver");
|
|
100
142
|
}
|
|
101
143
|
transporter;
|
|
102
144
|
constructor(config) {
|
|
103
|
-
this.transporter =
|
|
145
|
+
this.transporter = nodemailer2.createTransport({
|
|
104
146
|
host: config.host,
|
|
105
147
|
port: config.port,
|
|
106
148
|
secure: config.port === 465,
|
|
@@ -123,38 +165,152 @@ var SMTPDriver = class {
|
|
|
123
165
|
}
|
|
124
166
|
};
|
|
125
167
|
|
|
126
|
-
// src/
|
|
127
|
-
import
|
|
128
|
-
|
|
168
|
+
// src/Drivers/LOGDriver.ts
|
|
169
|
+
import nodemailer3 from "nodemailer";
|
|
170
|
+
import Stream from "stream";
|
|
171
|
+
var LOGDriver = class {
|
|
129
172
|
static {
|
|
130
|
-
__name(this, "
|
|
173
|
+
__name(this, "LOGDriver");
|
|
131
174
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
175
|
+
transporter;
|
|
176
|
+
constructor(_config) {
|
|
177
|
+
this.transporter = nodemailer3.createTransport({
|
|
178
|
+
streamTransport: true,
|
|
179
|
+
newline: "unix"
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async send(options) {
|
|
183
|
+
this.transporter.sendMail(options, (err, info) => {
|
|
184
|
+
if (err)
|
|
185
|
+
throw err;
|
|
186
|
+
console.log(info.envelope);
|
|
187
|
+
console.log(info.messageId);
|
|
188
|
+
info.message instanceof Stream.Readable && info.message.pipe(process.stdout);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/Drivers/SendMailDriver.ts
|
|
194
|
+
import nodemailer4 from "nodemailer";
|
|
195
|
+
var SendMailDriver = class {
|
|
196
|
+
static {
|
|
197
|
+
__name(this, "SendMailDriver");
|
|
198
|
+
}
|
|
199
|
+
transporter;
|
|
200
|
+
constructor(config) {
|
|
201
|
+
this.transporter = nodemailer4.createTransport({
|
|
202
|
+
sendmail: true,
|
|
203
|
+
path: config.path
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async send(options) {
|
|
207
|
+
return await this.transporter.sendMail({
|
|
208
|
+
to: options.to,
|
|
209
|
+
cc: options.cc,
|
|
210
|
+
bcc: options.bcc,
|
|
211
|
+
subject: options.subject,
|
|
212
|
+
html: options.html,
|
|
213
|
+
text: options.text,
|
|
214
|
+
attachments: options.attachments
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/Service.ts
|
|
220
|
+
var Service = class {
|
|
221
|
+
static {
|
|
222
|
+
__name(this, "Service");
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Initializes the mailer service with the given application instance
|
|
226
|
+
*
|
|
227
|
+
* @param app
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
static init(app) {
|
|
231
|
+
const view = app.make("view");
|
|
232
|
+
const config = app.make("config");
|
|
233
|
+
const mailConfig = {
|
|
234
|
+
/**
|
|
235
|
+
* SMTP configuration with fallback defaults
|
|
236
|
+
*/
|
|
237
|
+
smtp: {
|
|
138
238
|
host: config.get("mail.mailers.smtp.host", "smtp.mailtrap.io"),
|
|
139
239
|
port: Number(config.get("mail.mailers.smtp.port", 2525)),
|
|
140
240
|
auth: {
|
|
141
241
|
user: config.get("mail.mailers.smtp.username", ""),
|
|
142
242
|
pass: config.get("mail.mailers.smtp.password", "")
|
|
143
243
|
},
|
|
144
|
-
opportunisticTLS: config.get("mail.
|
|
244
|
+
opportunisticTLS: config.get("mail.mail\u6C14\u7684mailers.smtp.encryption") === "tls",
|
|
145
245
|
connectionTimeout: config.get("mail.mailers.smtp.timeout"),
|
|
146
246
|
debug: false
|
|
147
|
-
}
|
|
148
|
-
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* SES configuration with fallback defaults
|
|
250
|
+
*/
|
|
251
|
+
ses: {
|
|
252
|
+
key: config.get("services.ses.key", ""),
|
|
253
|
+
secret: config.get("services.ses.secret", ""),
|
|
254
|
+
region: config.get("services.ses.region", "us-east-1"),
|
|
255
|
+
maxConnections: config.get("mail.mailers.ses.connections", 10),
|
|
256
|
+
sendingRate: config.get("mail.mailers.ses.rate", 5)
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* Sendmail configuration with fallback default path
|
|
260
|
+
*/
|
|
261
|
+
sendmail: {
|
|
262
|
+
path: config.get("mail.mailers.sendmail.path", "sendmail")
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const driver = {
|
|
266
|
+
/**
|
|
267
|
+
* SES driver factory
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
ses: () => new SESDriver(mailConfig.ses),
|
|
271
|
+
/**
|
|
272
|
+
* SMTP driver factory
|
|
273
|
+
* @returns
|
|
274
|
+
*/
|
|
275
|
+
smtp: () => new SMTPDriver(mailConfig.smtp),
|
|
276
|
+
/**
|
|
277
|
+
* LOG driver factory for debugging
|
|
278
|
+
* @returns
|
|
279
|
+
*/
|
|
280
|
+
log: () => new LOGDriver(mailConfig.smtp),
|
|
281
|
+
/**
|
|
282
|
+
* Sendmail driver factory
|
|
283
|
+
* @returns
|
|
284
|
+
*/
|
|
285
|
+
sendmail: () => new SendMailDriver(mailConfig.sendmail)
|
|
286
|
+
};
|
|
287
|
+
return new Mailer((driver[config.get("mail.default")] ?? driver.smtp)(), async (viewPath, data) => await view(viewPath, data));
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// src/Providers/MailServiceProvider.ts
|
|
292
|
+
import { ServiceProvider } from "@h3ravel/core";
|
|
293
|
+
var MailServiceProvider = class extends ServiceProvider {
|
|
294
|
+
static {
|
|
295
|
+
__name(this, "MailServiceProvider");
|
|
296
|
+
}
|
|
297
|
+
static priority = 990;
|
|
298
|
+
register() {
|
|
299
|
+
this.app.singleton(Mailer, () => {
|
|
300
|
+
return Service.init(this.app);
|
|
149
301
|
});
|
|
150
302
|
}
|
|
151
303
|
boot() {
|
|
152
304
|
}
|
|
153
305
|
};
|
|
154
306
|
export {
|
|
307
|
+
LOGDriver,
|
|
155
308
|
MailServiceProvider,
|
|
156
309
|
Mailable,
|
|
157
310
|
Mailer,
|
|
158
|
-
|
|
311
|
+
SESDriver,
|
|
312
|
+
SMTPDriver,
|
|
313
|
+
SendMailDriver,
|
|
314
|
+
Service
|
|
159
315
|
};
|
|
160
316
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Mailable.ts","../src/Mailer.ts","../src/Drivers/SMTPDriver.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["import type { SendMailOptions } from \"./Contracts/Mailer\";\n\nexport abstract class Mailable {\n protected toAddress?: string;\n protected ccAddresses?: string[];\n protected bccAddresses?: string[];\n protected subjectText?: string;\n protected htmlContent?: string;\n protected textContent?: string;\n protected viewPath?: string;\n protected viewData?: Record<string, any>;\n protected attachmentsList?: SendMailOptions['attachments'];\n\n to (address: string) {\n this.toAddress = address;\n return this;\n }\n\n cc (...addresses: string[]) {\n this.ccAddresses = addresses;\n return this;\n }\n\n bcc (...addresses: string[]) {\n this.bccAddresses = addresses;\n return this;\n }\n\n subject (subject: string) {\n this.subjectText = subject;\n return this;\n }\n\n html (html: string) {\n this.htmlContent = html;\n return this;\n }\n\n text (text: string) {\n this.textContent = text;\n return this;\n }\n\n view (path: string, data: Record<string, any> = {}) {\n this.viewPath = path;\n this.viewData = data;\n return this;\n }\n\n attach (filename: string, filePath: string) {\n if (!this.attachmentsList) this.attachmentsList = [];\n this.attachmentsList.push({ filename, path: filePath });\n return this;\n }\n\n /**\n * Child classes should define build() like in Laravel\n */\n abstract build (): Promise<this> | this;\n\n /**\n * Called internally by Mailer\n */\n getMessageOptions (): SendMailOptions {\n return {\n to: this.toAddress,\n cc: this.ccAddresses,\n bcc: this.bccAddresses,\n subject: this.subjectText,\n html: this.htmlContent,\n text: this.textContent,\n viewPath: this.viewPath,\n viewData: this.viewData,\n attachments: this.attachmentsList\n };\n }\n}\n","import { MailDriverContract } from './Contracts/Mailer';\nimport { Mailable } from './Mailable';\n\nexport class Mailer {\n constructor(\n private driver: MailDriverContract,\n private edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>\n ) { }\n\n async send (mailable: Mailable) {\n await mailable.build();\n\n const options = mailable.getMessageOptions();\n\n if (options.viewPath && !options.html) {\n options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});\n }\n\n return this.driver.send(options);\n }\n}\n","import nodemailer, { type SendMailOptions, type TransportOptions } from 'nodemailer';\n\nimport { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';\n\nexport class SMTPDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SMTPConfig) {\n this.transporter = nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.port === 465, // auto decide based on port\n auth: {\n user: config.auth.user,\n pass: config.auth.pass\n }\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import { Mailer } from '../Mailer';\nimport { SMTPConfig } from '../Contracts/Mailer';\nimport { SMTPDriver } from '../Drivers/SMTPDriver';\nimport { ServiceProvider } from '@h3ravel/core';\n\n/**\n * Mail delivery setup.\n * \n * Bind Mailer service.\n * Load mail drivers (SMTP, SES, etc.).\n * Register Mail facade.\n * \n */\nexport class MailServiceProvider extends ServiceProvider {\n public static priority = 990;\n register () {\n /**\n * Register Mailer instance\n */\n\n this.app.singleton<any>('mailer', () => {\n // this.app.bind(Mailer, () => {\n const view = this.app.make('view');\n const config = this.app.make('config');\n\n const smtpConfig: SMTPConfig = {\n host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),\n port: Number(config.get('mail.mailers.smtp.port', 2525)),\n auth: {\n user: config.get('mail.mailers.smtp.username', ''),\n pass: config.get('mail.mailers.smtp.password', ''),\n },\n opportunisticTLS: config.get('mail.mailers.smtp.encryption') === 'tls',\n connectionTimeout: config.get('mail.mailers.smtp.timeout'),\n debug: false,\n };\n\n return new Mailer(\n new SMTPDriver(smtpConfig),\n async (viewPath, data) => await view(viewPath, data)\n );\n });\n }\n\n boot () {\n /**\n * Add logic here for global mail \"from\" address and others\n */\n }\n}\n"],"mappings":";;;;AAEO,IAAeA,WAAf,MAAeA;EAAtB,OAAsBA;;;EACRC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEVC,GAAIC,SAAiB;AACjB,SAAKV,YAAYU;AACjB,WAAO;EACX;EAEAC,MAAOC,WAAqB;AACxB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,OAAQD,WAAqB;AACzB,SAAKV,eAAeU;AACpB,WAAO;EACX;EAEAE,QAASA,SAAiB;AACtB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMC,MAAcC,OAA4B,CAAC,GAAG;AAChD,SAAKb,WAAWY;AAChB,SAAKX,WAAWY;AAChB,WAAO;EACX;EAEAC,OAAQC,UAAkBC,UAAkB;AACxC,QAAI,CAAC,KAAKd;AAAiB,WAAKA,kBAAkB,CAAA;AAClD,SAAKA,gBAAgBe,KAAK;MAAEF;MAAUH,MAAMI;IAAS,CAAA;AACrD,WAAO;EACX;;;;EAUAE,oBAAsC;AAClC,WAAO;MACHf,IAAI,KAAKT;MACTW,IAAI,KAAKV;MACTY,KAAK,KAAKX;MACVY,SAAS,KAAKX;MACdY,MAAM,KAAKX;MACXY,MAAM,KAAKX;MACXC,UAAU,KAAKA;MACfC,UAAU,KAAKA;MACfkB,aAAa,KAAKjB;IACtB;EACJ;AACJ;;;ACzEO,IAAMkB,SAAN,MAAMA;EAAb,OAAaA;;;;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;QAClDG,MAAM;UACFC,MAAMP,OAAOG,IAAI,8BAA8B,EAAA;UAC/CK,MAAMR,OAAOG,IAAI,8BAA8B,EAAA;QACnD;QACAM,kBAAkBT,OAAOG,IAAI,8BAAA,MAAoC;QACjEO,mBAAmBV,OAAOG,IAAI,2BAAA;QAC9BQ,OAAO;MACX;AAEA,aAAO,IAAIC,OACP,IAAIC,WAAWZ,UAAAA,GACf,OAAOa,UAAUC,SAAS,MAAMjB,KAAKgB,UAAUC,IAAAA,CAAAA;IAEvD,CAAA;EACJ;EAEAC,OAAQ;EAIR;AACJ;","names":["Mailable","toAddress","ccAddresses","bccAddresses","subjectText","htmlContent","textContent","viewPath","viewData","attachmentsList","to","address","cc","addresses","bcc","subject","html","text","view","path","data","attach","filename","filePath","push","getMessageOptions","attachments","Mailer","driver","edgeRenderer","send","mailable","build","options","getMessageOptions","viewPath","html","viewData","nodemailer","SMTPDriver","transporter","config","nodemailer","createTransport","host","port","secure","auth","user","pass","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","ServiceProvider","MailServiceProvider","ServiceProvider","priority","register","app","singleton","view","make","config","smtpConfig","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","Mailer","SMTPDriver","viewPath","data","boot"]}
|
|
1
|
+
{"version":3,"sources":["../src/Mailable.ts","../src/Mailer.ts","../src/Drivers/SESDriver.ts","../src/Drivers/SMTPDriver.ts","../src/Drivers/LOGDriver.ts","../src/Drivers/SendMailDriver.ts","../src/Service.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["import type { SendMailOptions } from \"./Contracts/Mailer\";\n\nexport abstract class Mailable {\n protected toAddress?: string;\n protected ccAddresses?: string[];\n protected bccAddresses?: string[];\n protected subjectText?: string;\n protected htmlContent?: string;\n protected textContent?: string;\n protected viewPath?: string;\n protected viewData?: Record<string, any>;\n protected attachmentsList?: SendMailOptions['attachments'];\n\n to (address: string) {\n this.toAddress = address;\n return this;\n }\n\n cc (...addresses: string[]) {\n this.ccAddresses = addresses;\n return this;\n }\n\n bcc (...addresses: string[]) {\n this.bccAddresses = addresses;\n return this;\n }\n\n subject (subject: string) {\n this.subjectText = subject;\n return this;\n }\n\n html (html: string) {\n this.htmlContent = html;\n return this;\n }\n\n text (text: string) {\n this.textContent = text;\n return this;\n }\n\n view (path: string, data: Record<string, any> = {}) {\n this.viewPath = path;\n this.viewData = data;\n return this;\n }\n\n attach (filename: string, filePath: string) {\n if (!this.attachmentsList) this.attachmentsList = [];\n this.attachmentsList.push({ filename, path: filePath });\n return this;\n }\n\n /**\n * Child classes should define build() like in Laravel\n */\n abstract build (): Promise<this> | this;\n\n /**\n * Called internally by Mailer\n */\n getMessageOptions (): SendMailOptions {\n return {\n to: this.toAddress,\n cc: this.ccAddresses,\n bcc: this.bccAddresses,\n subject: this.subjectText,\n html: this.htmlContent,\n text: this.textContent,\n viewPath: this.viewPath,\n viewData: this.viewData,\n attachments: this.attachmentsList\n };\n }\n}\n","import { DeliveryReport, MailDriverContract } from './Contracts/Mailer';\n\nimport { Mailable } from './Mailable';\n\nexport class Mailer {\n constructor(\n private driver: MailDriverContract,\n private edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>\n ) { }\n\n async send (mailable: Mailable): Promise<DeliveryReport | undefined | void> {\n await mailable.build();\n\n const options = mailable.getMessageOptions();\n\n if (options.viewPath && !options.html) {\n options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});\n }\n\n try {\n return this.driver.send(options);\n } catch (error) {\n return\n }\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SESConfig } from '../Contracts/Mailer';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport class SESDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SESConfig) {\n\n // 1. Configure the AWS SDK client (uses default credential chain if omitted)\n const sesClient = new SESv2Client({\n region: config.region,\n credentials: {\n accessKeyId: config.key,\n secretAccessKey: config.secret\n }\n });\n\n // 2. Create a Nodemailer transport that points at SES\n this.transporter = nodemailer.createTransport({\n SES: { sesClient, SendEmailCommand },\n maxConnections: config.maxConnections,\n sendingRate: config.sendingRate\n });\n }\n\n async send (options: SendMailOptions) {\n // 3. Send the message\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';\n\nexport class SMTPDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SMTPConfig) {\n this.transporter = nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.port === 465, // auto decide based on port\n auth: {\n user: config.auth.user,\n pass: config.auth.pass\n }\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract } from '../Contracts/Mailer';\nimport Stream from 'stream';\n\nexport class LOGDriver implements MailDriverContract {\n private transporter\n\n constructor(_config: any) {\n this.transporter = nodemailer.createTransport({\n streamTransport: true,\n newline: \"unix\",\n });\n }\n\n async send (options: SendMailOptions) {\n this.transporter.sendMail(options, (err, info) => {\n if (err) throw err;\n console.log(info.envelope);\n console.log(info.messageId);\n // Pipe the raw RFC 822 message to STDOUT\n info.message instanceof Stream.Readable && info.message.pipe(process.stdout);\n }\n );\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SendMailConfig } from '../Contracts/Mailer';\n\nexport class SendMailDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SendMailConfig) {\n this.transporter = nodemailer.createTransport({\n sendmail: true,\n path: config.path,\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import { Application } from \"@h3ravel/core\";\nimport { SendMailConfig, SESConfig, SMTPConfig } from \"./Contracts/Mailer\";\nimport { SESDriver } from \"./Drivers/SESDriver\";\nimport { SMTPDriver } from \"./Drivers/SMTPDriver\";\nimport { LOGDriver } from \"./Drivers/LOGDriver\";\nimport { SendMailDriver } from \"./Drivers/SendMailDriver\";\nimport { Mailer } from \"./Mailer\";\n\n/**\n * Service class to initialize and configure the mailer service\n */\nexport class Service {\n /**\n * Initializes the mailer service with the given application instance\n * \n * @param app \n * @returns \n */\n static init (app: Application) {\n /**\n * Resolve the view and config services from the container\n */\n const view = app.make('view');\n const config = app.make('config');\n\n /**\n * Configure mailer settings for different drivers\n */\n const mailConfig = {\n /**\n * SMTP configuration with fallback defaults\n */\n smtp: <SMTPConfig>{\n host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),\n port: Number(config.get('mail.mailers.smtp.port', 2525)),\n auth: {\n user: config.get('mail.mailers.smtp.username', ''),\n pass: config.get('mail.mailers.smtp.password', ''),\n },\n opportunisticTLS: config.get('mail.mail气的mailers.smtp.encryption') === 'tls',\n connectionTimeout: config.get('mail.mailers.smtp.timeout'),\n debug: false,\n },\n /**\n * SES configuration with fallback defaults\n */\n ses: <SESConfig>{\n key: config.get('services.ses.key', ''),\n secret: config.get('services.ses.secret', ''),\n region: config.get('services.ses.region', 'us-east-1'),\n maxConnections: config.get('mail.mailers.ses.connections', 10),\n sendingRate: config.get('mail.mailers.ses.rate', 5),\n },\n /**\n * Sendmail configuration with fallback default path\n */\n sendmail: <SendMailConfig>{\n path: config.get('mail.mailers.sendmail.path', 'sendmail'),\n },\n };\n\n /**\n * Define available mail drivers\n */\n const driver = {\n /**\n * SES driver factory\n * @returns \n */\n ses: () => new SESDriver(mailConfig.ses),\n /**\n * SMTP driver factory\n * @returns \n */\n smtp: () => new SMTPDriver(mailConfig.smtp),\n /**\n * LOG driver factory for debugging\n * @returns \n */\n log: () => new LOGDriver(mailConfig.smtp),\n /**\n * Sendmail driver factory\n * @returns \n */\n sendmail: () => new SendMailDriver(mailConfig.sendmail),\n };\n\n /**\n * Initialize Mailer with the selected driver (default to SMTP if not specified)\n * and a view rendering function\n */\n return new Mailer(\n (driver[config.get('mail.default') as keyof typeof driver] ?? driver.smtp)(),\n async (viewPath, data) => await view(viewPath, data)\n );\n }\n}\n","import { SESConfig, SMTPConfig, SendMailConfig } from '../Contracts/Mailer';\n\nimport { LOGDriver } from '../Drivers/LOGDriver';\nimport { Mailer } from '../Mailer';\nimport { SESDriver } from '../Drivers/SESDriver';\nimport { SMTPDriver } from '../Drivers/SMTPDriver';\nimport { SendMailDriver } from '../Drivers/SendMailDriver';\nimport { Service } from '../Service';\nimport { ServiceProvider } from '@h3ravel/core';\n\n/**\n * Mail delivery setup.\n * \n * Bind Mailer service.\n * Load mail drivers (SMTP, SES, etc.).\n * Register Mail facade.\n * \n */\nexport class MailServiceProvider extends ServiceProvider {\n public static priority = 990;\n register () {\n /**\n * Register Mailer instance\n */\n this.app.singleton<any>(Mailer, () => {\n return Service.init(this.app)\n });\n }\n\n boot () {\n /**\n * Add logic here for global mail \"from\" address and others\n */\n }\n}\n"],"mappings":";;;;AAEO,IAAeA,WAAf,MAAeA;EAAtB,OAAsBA;;;EACRC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEVC,GAAIC,SAAiB;AACjB,SAAKV,YAAYU;AACjB,WAAO;EACX;EAEAC,MAAOC,WAAqB;AACxB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,OAAQD,WAAqB;AACzB,SAAKV,eAAeU;AACpB,WAAO;EACX;EAEAE,QAASA,SAAiB;AACtB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,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AalB,OAAOI,IAAI,yBAAyB,CAAA;MACrD;;;;MAIAe,UAA0B;QACtBC,MAAMpB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMiB,SAAS;;;;;MAKXR,KAAK,MAAM,IAAIS,UAAUrB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAIqB,WAAWtB,WAAWC,IAAI;;;;;MAK1CsB,KAAK,MAAM,IAAIC,UAAUxB,WAAWC,IAAI;;;;;MAKxCiB,UAAU,MAAM,IAAIO,eAAezB,WAAWkB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOrB,OAAOI,IAAI,cAAA,CAAA,KAA2CiB,OAAOnB,MAAG,GACxE,OAAO0B,UAAUC,SAAS,MAAM/B,KAAK8B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACxFA,SAASC,uBAAuB;AAUzB,IAAMC,sBAAN,cAAkCC,gBAAAA;EAfzC,OAeyCA;;;EACrC,OAAcC,WAAW;EACzBC,WAAY;AAIR,SAAKC,IAAIC,UAAeC,QAAQ,MAAA;AAC5B,aAAOC,QAAQC,KAAK,KAAKJ,GAAG;IAChC,CAAA;EACJ;EAEAK,OAAQ;EAIR;AACJ;","names":["Mailable","toAddress","ccAddresses","bccAddresses","subjectText","htmlContent","textContent","viewPath","viewData","attachmentsList","to","address","cc","addresses","bcc","subject","html","text","view","path","data","attach","filename","filePath","push","getMessageOptions","attachments","Mailer","driver","edgeRenderer","send","mailable","build","options","getMessageOptions","viewPath","html","viewData","error","nodemailer","SendEmailCommand","SESv2Client","SESDriver","transporter","config","sesClient","SESv2Client","region","credentials","accessKeyId","key","secretAccessKey","secret","nodemailer","createTransport","SES","SendEmailCommand","maxConnections","sendingRate","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","nodemailer","SMTPDriver","transporter","config","nodemailer","createTransport","host","port","secure","auth","user","pass","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","nodemailer","Stream","LOGDriver","transporter","_config","nodemailer","createTransport","streamTransport","newline","send","options","sendMail","err","info","console","log","envelope","messageId","message","Stream","Readable","pipe","process","stdout","nodemailer","SendMailDriver","transporter","config","nodemailer","createTransport","sendmail","path","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","Service","init","app","view","make","config","mailConfig","smtp","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","ses","key","secret","region","maxConnections","sendingRate","sendmail","path","driver","SESDriver","SMTPDriver","log","LOGDriver","SendMailDriver","Mailer","viewPath","data","ServiceProvider","MailServiceProvider","ServiceProvider","priority","register","app","singleton","Mailer","Service","init","boot"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/mail",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Mail drivers and templates system for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"directory": "packages/mail"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@h3ravel/core": "^1.
|
|
29
|
+
"@h3ravel/core": "^1.5.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/nodemailer": "^6.4.17",
|
|
33
33
|
"typescript": "^5.4.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@aws-sdk/client-sesv2": "^3.864.0",
|
|
36
37
|
"nodemailer": "^7.0.5"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|