@h3ravel/mail 10.0.0 → 11.0.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 CHANGED
@@ -29,8 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
31
  // src/index.ts
32
- var src_exports = {};
33
- __export(src_exports, {
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
34
  LOGDriver: () => LOGDriver,
35
35
  MailServiceProvider: () => MailServiceProvider,
36
36
  Mailable: () => Mailable,
@@ -40,7 +40,127 @@ __export(src_exports, {
40
40
  SendMailDriver: () => SendMailDriver,
41
41
  Service: () => Service
42
42
  });
43
- module.exports = __toCommonJS(src_exports);
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/Drivers/LOGDriver.ts
46
+ var import_nodemailer = __toESM(require("nodemailer"), 1);
47
+ var import_stream = __toESM(require("stream"), 1);
48
+ var LOGDriver = class {
49
+ static {
50
+ __name(this, "LOGDriver");
51
+ }
52
+ transporter;
53
+ constructor(_config) {
54
+ this.transporter = import_nodemailer.default.createTransport({
55
+ streamTransport: true,
56
+ newline: "unix"
57
+ });
58
+ }
59
+ async send(options) {
60
+ this.transporter.sendMail(options, (err, info) => {
61
+ if (err) throw err;
62
+ console.log(info.envelope);
63
+ console.log(info.messageId);
64
+ info.message instanceof import_stream.default.Readable && info.message.pipe(process.stdout);
65
+ });
66
+ }
67
+ };
68
+
69
+ // src/Drivers/SendMailDriver.ts
70
+ var import_nodemailer2 = __toESM(require("nodemailer"), 1);
71
+ var SendMailDriver = class {
72
+ static {
73
+ __name(this, "SendMailDriver");
74
+ }
75
+ transporter;
76
+ constructor(config) {
77
+ this.transporter = import_nodemailer2.default.createTransport({
78
+ sendmail: true,
79
+ path: config.path
80
+ });
81
+ }
82
+ async send(options) {
83
+ return await this.transporter.sendMail({
84
+ to: options.to,
85
+ cc: options.cc,
86
+ bcc: options.bcc,
87
+ subject: options.subject,
88
+ html: options.html,
89
+ text: options.text,
90
+ attachments: options.attachments
91
+ });
92
+ }
93
+ };
94
+
95
+ // src/Drivers/SESDriver.ts
96
+ var import_nodemailer3 = __toESM(require("nodemailer"), 1);
97
+ var import_client_sesv2 = require("@aws-sdk/client-sesv2");
98
+ var SESDriver = class {
99
+ static {
100
+ __name(this, "SESDriver");
101
+ }
102
+ transporter;
103
+ constructor(config) {
104
+ const sesClient = new import_client_sesv2.SESv2Client({
105
+ region: config.region,
106
+ credentials: {
107
+ accessKeyId: config.key,
108
+ sessionToken: config.token,
109
+ secretAccessKey: config.secret
110
+ }
111
+ });
112
+ this.transporter = import_nodemailer3.default.createTransport({
113
+ SES: {
114
+ sesClient,
115
+ SendEmailCommand: import_client_sesv2.SendEmailCommand
116
+ },
117
+ maxConnections: config.maxConnections,
118
+ sendingRate: config.sendingRate
119
+ });
120
+ }
121
+ async send(options) {
122
+ return await this.transporter.sendMail({
123
+ to: options.to,
124
+ cc: options.cc,
125
+ bcc: options.bcc,
126
+ subject: options.subject,
127
+ html: options.html,
128
+ text: options.text,
129
+ attachments: options.attachments
130
+ });
131
+ }
132
+ };
133
+
134
+ // src/Drivers/SMTPDriver.ts
135
+ var import_nodemailer4 = __toESM(require("nodemailer"), 1);
136
+ var SMTPDriver = class {
137
+ static {
138
+ __name(this, "SMTPDriver");
139
+ }
140
+ transporter;
141
+ constructor(config) {
142
+ this.transporter = import_nodemailer4.default.createTransport({
143
+ host: config.host,
144
+ port: config.port,
145
+ secure: config.port === 465,
146
+ auth: {
147
+ user: config.auth.user,
148
+ pass: config.auth.pass
149
+ }
150
+ });
151
+ }
152
+ async send(options) {
153
+ return await this.transporter.sendMail({
154
+ to: options.to,
155
+ cc: options.cc,
156
+ bcc: options.bcc,
157
+ subject: options.subject,
158
+ html: options.html,
159
+ text: options.text,
160
+ attachments: options.attachments
161
+ });
162
+ }
163
+ };
44
164
 
45
165
  // src/Mailable.ts
46
166
  var Mailable = class {
@@ -86,8 +206,7 @@ var Mailable = class {
86
206
  return this;
87
207
  }
88
208
  attach(filename, filePath) {
89
- if (!this.attachmentsList)
90
- this.attachmentsList = [];
209
+ if (!this.attachmentsList) this.attachmentsList = [];
91
210
  this.attachmentsList.push({
92
211
  filename,
93
212
  path: filePath
@@ -137,127 +256,6 @@ var Mailer = class {
137
256
  }
138
257
  };
139
258
 
140
- // src/Drivers/SESDriver.ts
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
- sessionToken: config.token,
154
- secretAccessKey: config.secret
155
- }
156
- });
157
- this.transporter = import_nodemailer.default.createTransport({
158
- SES: {
159
- sesClient,
160
- SendEmailCommand: import_client_sesv2.SendEmailCommand
161
- },
162
- maxConnections: config.maxConnections,
163
- sendingRate: config.sendingRate
164
- });
165
- }
166
- async send(options) {
167
- return await this.transporter.sendMail({
168
- to: options.to,
169
- cc: options.cc,
170
- bcc: options.bcc,
171
- subject: options.subject,
172
- html: options.html,
173
- text: options.text,
174
- attachments: options.attachments
175
- });
176
- }
177
- };
178
-
179
- // src/Drivers/SMTPDriver.ts
180
- var import_nodemailer2 = __toESM(require("nodemailer"), 1);
181
- var SMTPDriver = class {
182
- static {
183
- __name(this, "SMTPDriver");
184
- }
185
- transporter;
186
- constructor(config) {
187
- this.transporter = import_nodemailer2.default.createTransport({
188
- host: config.host,
189
- port: config.port,
190
- secure: config.port === 465,
191
- auth: {
192
- user: config.auth.user,
193
- pass: config.auth.pass
194
- }
195
- });
196
- }
197
- async send(options) {
198
- return await this.transporter.sendMail({
199
- to: options.to,
200
- cc: options.cc,
201
- bcc: options.bcc,
202
- subject: options.subject,
203
- html: options.html,
204
- text: options.text,
205
- attachments: options.attachments
206
- });
207
- }
208
- };
209
-
210
- // src/Drivers/LOGDriver.ts
211
- var import_nodemailer3 = __toESM(require("nodemailer"), 1);
212
- var import_stream = __toESM(require("stream"), 1);
213
- var LOGDriver = class {
214
- static {
215
- __name(this, "LOGDriver");
216
- }
217
- transporter;
218
- constructor(_config) {
219
- this.transporter = import_nodemailer3.default.createTransport({
220
- streamTransport: true,
221
- newline: "unix"
222
- });
223
- }
224
- async send(options) {
225
- this.transporter.sendMail(options, (err, info) => {
226
- if (err)
227
- throw err;
228
- console.log(info.envelope);
229
- console.log(info.messageId);
230
- info.message instanceof import_stream.default.Readable && info.message.pipe(process.stdout);
231
- });
232
- }
233
- };
234
-
235
- // src/Drivers/SendMailDriver.ts
236
- var import_nodemailer4 = __toESM(require("nodemailer"), 1);
237
- var SendMailDriver = class {
238
- static {
239
- __name(this, "SendMailDriver");
240
- }
241
- transporter;
242
- constructor(config) {
243
- this.transporter = import_nodemailer4.default.createTransport({
244
- sendmail: true,
245
- path: config.path
246
- });
247
- }
248
- async send(options) {
249
- return await this.transporter.sendMail({
250
- to: options.to,
251
- cc: options.cc,
252
- bcc: options.bcc,
253
- subject: options.subject,
254
- html: options.html,
255
- text: options.text,
256
- attachments: options.attachments
257
- });
258
- }
259
- };
260
-
261
259
  // src/Service.ts
262
260
  var Service = class {
263
261
  static {
@@ -310,22 +308,22 @@ var Service = class {
310
308
  * SES driver factory
311
309
  * @returns
312
310
  */
313
- ses: () => new SESDriver(mailConfig.ses),
311
+ ses: /* @__PURE__ */ __name(() => new SESDriver(mailConfig.ses), "ses"),
314
312
  /**
315
313
  * SMTP driver factory
316
314
  * @returns
317
315
  */
318
- smtp: () => new SMTPDriver(mailConfig.smtp),
316
+ smtp: /* @__PURE__ */ __name(() => new SMTPDriver(mailConfig.smtp), "smtp"),
319
317
  /**
320
318
  * LOG driver factory for debugging
321
319
  * @returns
322
320
  */
323
- log: () => new LOGDriver(mailConfig.smtp),
321
+ log: /* @__PURE__ */ __name(() => new LOGDriver(mailConfig.smtp), "log"),
324
322
  /**
325
323
  * Sendmail driver factory
326
324
  * @returns
327
325
  */
328
- sendmail: () => new SendMailDriver(mailConfig.sendmail)
326
+ sendmail: /* @__PURE__ */ __name(() => new SendMailDriver(mailConfig.sendmail), "sendmail")
329
327
  };
330
328
  return new Mailer((driver[config.get("mail.default")] ?? driver.smtp)(), async (viewPath, data) => await view(viewPath, data));
331
329
  }
@@ -1 +1 @@
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 sessionToken: config.token,\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 token: config.get('services.ses.token', ''),\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;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,UAAk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tBC,MAAMrB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMkB,SAAS;;;;;MAKXT,KAAK,MAAM,IAAIU,UAAUtB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAIsB,WAAWvB,WAAWC,IAAI;;;;;MAK1CuB,KAAK,MAAM,IAAIC,UAAUzB,WAAWC,IAAI;;;;;MAKxCkB,UAAU,MAAM,IAAIO,eAAe1B,WAAWmB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOtB,OAAOI,IAAI,cAAA,CAAA,KAA2CkB,OAAOpB,MAAG,GACxE,OAAO2B,UAAUC,SAAS,MAAMhC,KAAK+B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACzFA,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","sessionToken","token","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","token","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"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Drivers/LOGDriver.ts","../src/Drivers/SendMailDriver.ts","../src/Drivers/SESDriver.ts","../src/Drivers/SMTPDriver.ts","../src/Mailable.ts","../src/Mailer.ts","../src/Service.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["export * from './Contracts/Mailer'\nexport * from './Drivers/LOGDriver'\nexport * from './Drivers/SendMailDriver'\nexport * from './Drivers/SESDriver'\nexport * from './Drivers/SMTPDriver'\nexport * from './Helpers'\nexport * from './Mailable'\nexport * from './Mailer'\nexport * from './Providers/MailServiceProvider'\nexport * from './Service'\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 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 sessionToken: config.token,\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 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 { 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 token: config.get('services.ses.token', ''),\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;;;;;;;;;;;;;;ACAA,wBAAiD;AAGjD,oBAAmB;AAEZ,IAAMA,YAAN,MAAMA;EALb,OAKaA;;;EACDC;EAER,YAAYC,SAAc;AACtB,SAAKD,cAAcE,kBAAAA,QAAWC,gBAAgB;MAC1CC,iBAAiB;MACjBC,SAAS;IACb,CAAA;EACJ;EAEA,MAAMC,KAAMC,SAA0B;AAClC,SAAKP,YAAYQ,SAASD,SAAS,CAACE,KAAKC,SAAAA;AACrC,UAAID,IAAK,OAAMA;AACfE,cAAQC,IAAIF,KAAKG,QAAQ;AACzBF,cAAQC,IAAIF,KAAKI,SAAS;AAE1BJ,WAAKK,mBAAmBC,cAAAA,QAAOC,YAAYP,KAAKK,QAAQG,KAAKC,QAAQC,MAAM;IAC/E,CAAA;EAEJ;AACJ;;;ACzBA,IAAAC,qBAAiD;AAI1C,IAAMC,iBAAN,MAAMA;EAJb,OAIaA;;;EACDC;EAER,YAAYC,QAAwB;AAChC,SAAKD,cAAcE,mBAAAA,QAAWC,gBAAg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nD;IACJ;AAKA,UAAMkB,SAAS;;;;;MAKXT,KAAK,6BAAM,IAAIU,UAAUtB,WAAWY,GAAG,GAAlC;;;;;MAKLX,MAAM,6BAAM,IAAIsB,WAAWvB,WAAWC,IAAI,GAApC;;;;;MAKNuB,KAAK,6BAAM,IAAIC,UAAUzB,WAAWC,IAAI,GAAnC;;;;;MAKLkB,UAAU,6BAAM,IAAIO,eAAe1B,WAAWmB,QAAQ,GAA5C;IACd;AAMA,WAAO,IAAIQ,QACNN,OAAOtB,OAAOI,IAAI,cAAA,CAAA,KAA2CkB,OAAOpB,MAAG,GACxE,OAAO2B,UAAUC,SAAS,MAAMhC,KAAK+B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACzFA,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":["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","import_nodemailer","SESDriver","transporter","config","sesClient","SESv2Client","region","credentials","accessKeyId","key","sessionToken","token","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","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","Service","init","app","view","make","config","mailConfig","smtp","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","ses","key","token","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
@@ -4,8 +4,8 @@ import SESConnection__default from 'nodemailer/lib/ses-transport';
4
4
  import SMTPConnection from 'nodemailer/lib/smtp-connection';
5
5
  import * as SendmailTransport from 'nodemailer/lib/sendmail-transport';
6
6
  import SendmailTransport__default from 'nodemailer/lib/sendmail-transport';
7
- import { Application, ServiceProvider } from '@h3ravel/core';
8
7
  import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
8
+ import { ServiceProvider, Application } from '@h3ravel/core';
9
9
 
10
10
  interface DeliveryReport {
11
11
  accepted: string[];
@@ -55,6 +55,30 @@ interface MailDriverContract {
55
55
  send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
56
56
  }
57
57
 
58
+ declare class LOGDriver implements MailDriverContract {
59
+ private transporter;
60
+ constructor(_config: any);
61
+ send(options: SendMailOptions$1): Promise<void>;
62
+ }
63
+
64
+ declare class SendMailDriver implements MailDriverContract {
65
+ private transporter;
66
+ constructor(config: SendMailConfig);
67
+ send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
68
+ }
69
+
70
+ declare class SESDriver implements MailDriverContract {
71
+ private transporter;
72
+ constructor(config: SESConfig);
73
+ send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
74
+ }
75
+
76
+ declare class SMTPDriver implements MailDriverContract {
77
+ private transporter;
78
+ constructor(config: SMTPConfig);
79
+ send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
80
+ }
81
+
58
82
  declare abstract class Mailable {
59
83
  protected toAddress?: string;
60
84
  protected ccAddresses?: string[];
@@ -90,43 +114,6 @@ declare class Mailer {
90
114
  send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
91
115
  }
92
116
 
93
- /**
94
- * Service class to initialize and configure the mailer service
95
- */
96
- declare class Service {
97
- /**
98
- * Initializes the mailer service with the given application instance
99
- *
100
- * @param app
101
- * @returns
102
- */
103
- static init(app: Application): Mailer;
104
- }
105
-
106
- declare class LOGDriver implements MailDriverContract {
107
- private transporter;
108
- constructor(_config: any);
109
- send(options: SendMailOptions$1): Promise<void>;
110
- }
111
-
112
- declare class SESDriver implements MailDriverContract {
113
- private transporter;
114
- constructor(config: SESConfig);
115
- send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
116
- }
117
-
118
- declare class SMTPDriver implements MailDriverContract {
119
- private transporter;
120
- constructor(config: SMTPConfig);
121
- send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
122
- }
123
-
124
- declare class SendMailDriver implements MailDriverContract {
125
- private transporter;
126
- constructor(config: SendMailConfig);
127
- send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
128
- }
129
-
130
117
  /**
131
118
  * Mail delivery setup.
132
119
  *
@@ -141,4 +128,17 @@ declare class MailServiceProvider extends ServiceProvider {
141
128
  boot(): void;
142
129
  }
143
130
 
131
+ /**
132
+ * Service class to initialize and configure the mailer service
133
+ */
134
+ declare class Service {
135
+ /**
136
+ * Initializes the mailer service with the given application instance
137
+ *
138
+ * @param app
139
+ * @returns
140
+ */
141
+ static init(app: Application): Mailer;
142
+ }
143
+
144
144
  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
@@ -4,8 +4,8 @@ import SESConnection__default from 'nodemailer/lib/ses-transport';
4
4
  import SMTPConnection from 'nodemailer/lib/smtp-connection';
5
5
  import * as SendmailTransport from 'nodemailer/lib/sendmail-transport';
6
6
  import SendmailTransport__default from 'nodemailer/lib/sendmail-transport';
7
- import { Application, ServiceProvider } from '@h3ravel/core';
8
7
  import * as nodemailer_lib_smtp_transport from 'nodemailer/lib/smtp-transport';
8
+ import { ServiceProvider, Application } from '@h3ravel/core';
9
9
 
10
10
  interface DeliveryReport {
11
11
  accepted: string[];
@@ -55,6 +55,30 @@ interface MailDriverContract {
55
55
  send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
56
56
  }
57
57
 
58
+ declare class LOGDriver implements MailDriverContract {
59
+ private transporter;
60
+ constructor(_config: any);
61
+ send(options: SendMailOptions$1): Promise<void>;
62
+ }
63
+
64
+ declare class SendMailDriver implements MailDriverContract {
65
+ private transporter;
66
+ constructor(config: SendMailConfig);
67
+ send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
68
+ }
69
+
70
+ declare class SESDriver implements MailDriverContract {
71
+ private transporter;
72
+ constructor(config: SESConfig);
73
+ send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
74
+ }
75
+
76
+ declare class SMTPDriver implements MailDriverContract {
77
+ private transporter;
78
+ constructor(config: SMTPConfig);
79
+ send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
80
+ }
81
+
58
82
  declare abstract class Mailable {
59
83
  protected toAddress?: string;
60
84
  protected ccAddresses?: string[];
@@ -90,43 +114,6 @@ declare class Mailer {
90
114
  send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
91
115
  }
92
116
 
93
- /**
94
- * Service class to initialize and configure the mailer service
95
- */
96
- declare class Service {
97
- /**
98
- * Initializes the mailer service with the given application instance
99
- *
100
- * @param app
101
- * @returns
102
- */
103
- static init(app: Application): Mailer;
104
- }
105
-
106
- declare class LOGDriver implements MailDriverContract {
107
- private transporter;
108
- constructor(_config: any);
109
- send(options: SendMailOptions$1): Promise<void>;
110
- }
111
-
112
- declare class SESDriver implements MailDriverContract {
113
- private transporter;
114
- constructor(config: SESConfig);
115
- send(options: SendMailOptions$1): Promise<SESConnection.SentMessageInfo>;
116
- }
117
-
118
- declare class SMTPDriver implements MailDriverContract {
119
- private transporter;
120
- constructor(config: SMTPConfig);
121
- send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport.SentMessageInfo>;
122
- }
123
-
124
- declare class SendMailDriver implements MailDriverContract {
125
- private transporter;
126
- constructor(config: SendMailConfig);
127
- send(options: SendMailOptions$1): Promise<SendmailTransport.SentMessageInfo>;
128
- }
129
-
130
117
  /**
131
118
  * Mail delivery setup.
132
119
  *
@@ -141,4 +128,17 @@ declare class MailServiceProvider extends ServiceProvider {
141
128
  boot(): void;
142
129
  }
143
130
 
131
+ /**
132
+ * Service class to initialize and configure the mailer service
133
+ */
134
+ declare class Service {
135
+ /**
136
+ * Initializes the mailer service with the given application instance
137
+ *
138
+ * @param app
139
+ * @returns
140
+ */
141
+ static init(app: Application): Mailer;
142
+ }
143
+
144
144
  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
@@ -1,6 +1,126 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/Drivers/LOGDriver.ts
5
+ import nodemailer from "nodemailer";
6
+ import Stream from "stream";
7
+ var LOGDriver = class {
8
+ static {
9
+ __name(this, "LOGDriver");
10
+ }
11
+ transporter;
12
+ constructor(_config) {
13
+ this.transporter = nodemailer.createTransport({
14
+ streamTransport: true,
15
+ newline: "unix"
16
+ });
17
+ }
18
+ async send(options) {
19
+ this.transporter.sendMail(options, (err, info) => {
20
+ if (err) throw err;
21
+ console.log(info.envelope);
22
+ console.log(info.messageId);
23
+ info.message instanceof Stream.Readable && info.message.pipe(process.stdout);
24
+ });
25
+ }
26
+ };
27
+
28
+ // src/Drivers/SendMailDriver.ts
29
+ import nodemailer2 from "nodemailer";
30
+ var SendMailDriver = class {
31
+ static {
32
+ __name(this, "SendMailDriver");
33
+ }
34
+ transporter;
35
+ constructor(config) {
36
+ this.transporter = nodemailer2.createTransport({
37
+ sendmail: true,
38
+ path: config.path
39
+ });
40
+ }
41
+ async send(options) {
42
+ return await this.transporter.sendMail({
43
+ to: options.to,
44
+ cc: options.cc,
45
+ bcc: options.bcc,
46
+ subject: options.subject,
47
+ html: options.html,
48
+ text: options.text,
49
+ attachments: options.attachments
50
+ });
51
+ }
52
+ };
53
+
54
+ // src/Drivers/SESDriver.ts
55
+ import nodemailer3 from "nodemailer";
56
+ import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
57
+ var SESDriver = class {
58
+ static {
59
+ __name(this, "SESDriver");
60
+ }
61
+ transporter;
62
+ constructor(config) {
63
+ const sesClient = new SESv2Client({
64
+ region: config.region,
65
+ credentials: {
66
+ accessKeyId: config.key,
67
+ sessionToken: config.token,
68
+ secretAccessKey: config.secret
69
+ }
70
+ });
71
+ this.transporter = nodemailer3.createTransport({
72
+ SES: {
73
+ sesClient,
74
+ SendEmailCommand
75
+ },
76
+ maxConnections: config.maxConnections,
77
+ sendingRate: config.sendingRate
78
+ });
79
+ }
80
+ async send(options) {
81
+ return await this.transporter.sendMail({
82
+ to: options.to,
83
+ cc: options.cc,
84
+ bcc: options.bcc,
85
+ subject: options.subject,
86
+ html: options.html,
87
+ text: options.text,
88
+ attachments: options.attachments
89
+ });
90
+ }
91
+ };
92
+
93
+ // src/Drivers/SMTPDriver.ts
94
+ import nodemailer4 from "nodemailer";
95
+ var SMTPDriver = class {
96
+ static {
97
+ __name(this, "SMTPDriver");
98
+ }
99
+ transporter;
100
+ constructor(config) {
101
+ this.transporter = nodemailer4.createTransport({
102
+ host: config.host,
103
+ port: config.port,
104
+ secure: config.port === 465,
105
+ auth: {
106
+ user: config.auth.user,
107
+ pass: config.auth.pass
108
+ }
109
+ });
110
+ }
111
+ async send(options) {
112
+ return await this.transporter.sendMail({
113
+ to: options.to,
114
+ cc: options.cc,
115
+ bcc: options.bcc,
116
+ subject: options.subject,
117
+ html: options.html,
118
+ text: options.text,
119
+ attachments: options.attachments
120
+ });
121
+ }
122
+ };
123
+
4
124
  // src/Mailable.ts
5
125
  var Mailable = class {
6
126
  static {
@@ -45,8 +165,7 @@ var Mailable = class {
45
165
  return this;
46
166
  }
47
167
  attach(filename, filePath) {
48
- if (!this.attachmentsList)
49
- this.attachmentsList = [];
168
+ if (!this.attachmentsList) this.attachmentsList = [];
50
169
  this.attachmentsList.push({
51
170
  filename,
52
171
  path: filePath
@@ -96,127 +215,6 @@ var Mailer = class {
96
215
  }
97
216
  };
98
217
 
99
- // src/Drivers/SESDriver.ts
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
- sessionToken: config.token,
113
- secretAccessKey: config.secret
114
- }
115
- });
116
- this.transporter = nodemailer.createTransport({
117
- SES: {
118
- sesClient,
119
- SendEmailCommand
120
- },
121
- maxConnections: config.maxConnections,
122
- sendingRate: config.sendingRate
123
- });
124
- }
125
- async send(options) {
126
- return await this.transporter.sendMail({
127
- to: options.to,
128
- cc: options.cc,
129
- bcc: options.bcc,
130
- subject: options.subject,
131
- html: options.html,
132
- text: options.text,
133
- attachments: options.attachments
134
- });
135
- }
136
- };
137
-
138
- // src/Drivers/SMTPDriver.ts
139
- import nodemailer2 from "nodemailer";
140
- var SMTPDriver = class {
141
- static {
142
- __name(this, "SMTPDriver");
143
- }
144
- transporter;
145
- constructor(config) {
146
- this.transporter = nodemailer2.createTransport({
147
- host: config.host,
148
- port: config.port,
149
- secure: config.port === 465,
150
- auth: {
151
- user: config.auth.user,
152
- pass: config.auth.pass
153
- }
154
- });
155
- }
156
- async send(options) {
157
- return await this.transporter.sendMail({
158
- to: options.to,
159
- cc: options.cc,
160
- bcc: options.bcc,
161
- subject: options.subject,
162
- html: options.html,
163
- text: options.text,
164
- attachments: options.attachments
165
- });
166
- }
167
- };
168
-
169
- // src/Drivers/LOGDriver.ts
170
- import nodemailer3 from "nodemailer";
171
- import Stream from "stream";
172
- var LOGDriver = class {
173
- static {
174
- __name(this, "LOGDriver");
175
- }
176
- transporter;
177
- constructor(_config) {
178
- this.transporter = nodemailer3.createTransport({
179
- streamTransport: true,
180
- newline: "unix"
181
- });
182
- }
183
- async send(options) {
184
- this.transporter.sendMail(options, (err, info) => {
185
- if (err)
186
- throw err;
187
- console.log(info.envelope);
188
- console.log(info.messageId);
189
- info.message instanceof Stream.Readable && info.message.pipe(process.stdout);
190
- });
191
- }
192
- };
193
-
194
- // src/Drivers/SendMailDriver.ts
195
- import nodemailer4 from "nodemailer";
196
- var SendMailDriver = class {
197
- static {
198
- __name(this, "SendMailDriver");
199
- }
200
- transporter;
201
- constructor(config) {
202
- this.transporter = nodemailer4.createTransport({
203
- sendmail: true,
204
- path: config.path
205
- });
206
- }
207
- async send(options) {
208
- return await this.transporter.sendMail({
209
- to: options.to,
210
- cc: options.cc,
211
- bcc: options.bcc,
212
- subject: options.subject,
213
- html: options.html,
214
- text: options.text,
215
- attachments: options.attachments
216
- });
217
- }
218
- };
219
-
220
218
  // src/Service.ts
221
219
  var Service = class {
222
220
  static {
@@ -269,22 +267,22 @@ var Service = class {
269
267
  * SES driver factory
270
268
  * @returns
271
269
  */
272
- ses: () => new SESDriver(mailConfig.ses),
270
+ ses: /* @__PURE__ */ __name(() => new SESDriver(mailConfig.ses), "ses"),
273
271
  /**
274
272
  * SMTP driver factory
275
273
  * @returns
276
274
  */
277
- smtp: () => new SMTPDriver(mailConfig.smtp),
275
+ smtp: /* @__PURE__ */ __name(() => new SMTPDriver(mailConfig.smtp), "smtp"),
278
276
  /**
279
277
  * LOG driver factory for debugging
280
278
  * @returns
281
279
  */
282
- log: () => new LOGDriver(mailConfig.smtp),
280
+ log: /* @__PURE__ */ __name(() => new LOGDriver(mailConfig.smtp), "log"),
283
281
  /**
284
282
  * Sendmail driver factory
285
283
  * @returns
286
284
  */
287
- sendmail: () => new SendMailDriver(mailConfig.sendmail)
285
+ sendmail: /* @__PURE__ */ __name(() => new SendMailDriver(mailConfig.sendmail), "sendmail")
288
286
  };
289
287
  return new Mailer((driver[config.get("mail.default")] ?? driver.smtp)(), async (viewPath, data) => await view(viewPath, data));
290
288
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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 sessionToken: config.token,\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 token: config.get('services.ses.token', ''),\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,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;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,WAAWvB,WAAWC,IAAI;;;;;MAK1CuB,KAAK,MAAM,IAAIC,UAAUzB,WAAWC,IAAI;;;;;MAKxCkB,UAAU,MAAM,IAAIO,eAAe1B,WAAWmB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOtB,OAAOI,IAAI,cAAA,CAAA,KAA2CkB,OAAOpB,MAAG,GACxE,OAAO2B,UAAUC,SAAS,MAAMhC,KAAK+B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACzFA,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","sessionToken","token","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","token","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"]}
1
+ {"version":3,"sources":["../src/Drivers/LOGDriver.ts","../src/Drivers/SendMailDriver.ts","../src/Drivers/SESDriver.ts","../src/Drivers/SMTPDriver.ts","../src/Mailable.ts","../src/Mailer.ts","../src/Service.ts","../src/Providers/MailServiceProvider.ts"],"sourcesContent":["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 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 sessionToken: config.token,\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 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 { 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 token: config.get('services.ses.token', ''),\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,OAAOA,gBAA0C;AAGjD,OAAOC,YAAY;AAEZ,IAAMC,YAAN,MAAMA;EALb,OAKaA;;;EACDC;EAER,YAAYC,SAAc;AACtB,SAAKD,cAAcE,WAAWC,gBAAgB;MAC1CC,iBAAiB;MACjBC,SAAS;IACb,CAAA;EACJ;EAEA,MAAMC,KAAMC,SAA0B;AAClC,SAAKP,YAAYQ,SAASD,SAAS,CAACE,KAAKC,SAAAA;AACrC,UAAID,IAAK,OAAMA;AACfE,cAAQC,IAAIF,KAAKG,QAAQ;AACzBF,cAAQC,IAAIF,KAAKI,SAAS;AAE1BJ,WAAKK,mBAAmBC,OAAOC,YAAYP,KAAKK,QAAQG,KAAKC,QAAQC,MAAM;IAC/E,CAAA;EAEJ;AACJ;;;ACzBA,OAAOC,iBAA0C;AAI1C,IAAMC,iBAAN,MAAMA;EAJb,OAIaA;;;EACDC;EAER,YAAYC,QAAwB;AAChC,SAAKD,cAAcE,YAAWC,gBAAgB;MAC1CC,UAAU;MACVC,MAAMJ,OAAOI;IACjB,CAAA;EACJ;EAEA,MAAMC,KAAMC,SAA0B;AAClC,WAAO,MAAM,KAAKP,YAAYQ,SAAS;MACnCC,IAAIF,QAAQE;MACZC,IAAIH,QAAQG;MACZC,KAAKJ,QAAQI;MACbC,SAASL,QAAQK;MACjBC,MAAMN,QAAQM;MACdC,MAAMP,QAAQO;MACdC,aAAaR,QAAQQ;IACzB,CAAA;EACJ;AACJ;;;ACzBA,OAAOC,iBAA0C;AAGjD,SAASC,kBAAkBC,mBAAmB;AAEvC,IAAMC,YAAN,MAAMA;EALb,OAK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,SAAS,MAAMhC,KAAK+B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACzFA,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":["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","nodemailer","SendEmailCommand","SESv2Client","SESDriver","transporter","config","sesClient","SESv2Client","region","credentials","accessKeyId","key","sessionToken","token","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","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","Service","init","app","view","make","config","mailConfig","smtp","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","ses","key","token","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": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "Mail drivers and templates system for H3ravel.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,9 +8,9 @@
8
8
  "module": "./dist/index.js",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "files": [
@@ -26,7 +26,7 @@
26
26
  "directory": "packages/mail"
27
27
  },
28
28
  "peerDependencies": {
29
- "@h3ravel/core": "^1.6.0"
29
+ "@h3ravel/core": "^1.7.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/nodemailer": "^6.4.17",