@h3ravel/mail 9.0.0 → 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 +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -139,14 +139,25 @@ var Mailer = class {
|
|
|
139
139
|
|
|
140
140
|
// src/Drivers/SESDriver.ts
|
|
141
141
|
var import_nodemailer = __toESM(require("nodemailer"), 1);
|
|
142
|
+
var import_client_sesv2 = require("@aws-sdk/client-sesv2");
|
|
142
143
|
var SESDriver = class {
|
|
143
144
|
static {
|
|
144
145
|
__name(this, "SESDriver");
|
|
145
146
|
}
|
|
146
147
|
transporter;
|
|
147
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
|
+
});
|
|
148
156
|
this.transporter = import_nodemailer.default.createTransport({
|
|
149
|
-
SES:
|
|
157
|
+
SES: {
|
|
158
|
+
sesClient,
|
|
159
|
+
SendEmailCommand: import_client_sesv2.SendEmailCommand
|
|
160
|
+
},
|
|
150
161
|
maxConnections: config.maxConnections,
|
|
151
162
|
sendingRate: config.sendingRate
|
|
152
163
|
});
|
|
@@ -279,7 +290,9 @@ var Service = class {
|
|
|
279
290
|
* SES configuration with fallback defaults
|
|
280
291
|
*/
|
|
281
292
|
ses: {
|
|
282
|
-
|
|
293
|
+
key: config.get("services.ses.key", ""),
|
|
294
|
+
secret: config.get("services.ses.secret", ""),
|
|
295
|
+
region: config.get("services.ses.region", "us-east-1"),
|
|
283
296
|
maxConnections: config.get("mail.mailers.ses.connections", 10),
|
|
284
297
|
sendingRate: config.get("mail.mailers.ses.rate", 5)
|
|
285
298
|
},
|
package/dist/index.cjs.map
CHANGED
|
@@ -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';\n\nexport class SESDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SESConfig) {\n this.transporter = nodemailer.createTransport({\n SES: config.SES,\n maxConnections: config.maxConnections,\n sendingRate: config.sendingRate\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, 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 SES: config.get('mail.mailers.ses.transport', 'ses'),\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,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;;;ACxEO,IAAMkB,SAAN,MAAMA;EAAb,OAAaA;;;;;EACT,YACYC,QACAC,cACV;SAFUD,SAAAA;SACAC,eAAAA;EACR;EAEJ,MAAMC,KAAMC,UAAgE;AACxE,UAAMA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AA0B,IAAA,CAAA;QAClDG,MAAM;UACFC,MAAMR,OAAOI,IAAI,8BAA8B,EAAA;UAC/CK,MAAMT,OAAOI,IAAI,8BAA8B,EAAA;QACnD;QACAM,kBAAkBV,OAAOI,IAAI,8CAAA,MAA0C;QACvEO,mBAAmBX,OAAOI,IAAI,2BAAA;QAC9BQ,OAAO;MACX;;;;MAIAC,KAAgB;QACZC,KAAKd,OAAOI,IAAI,8BAA8B,KAAA;QAC9CW,gBAAgBf,OAAOI,IAAI,gCAAgC,EAAA;QAC3DY,aAAahB,OAAOI,IAAI,yBAAyB,CAAA;MACrD;;;;MAIAa,UAA0B;QACtBC,MAAMlB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMe,SAAS;;;;;MAKXN,KAAK,MAAM,IAAIO,UAAUnB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAImB,WAAWpB,WAAWC,IAAI;;;;;MAK1CoB,KAAK,MAAM,IAAIC,UAAUtB,WAAWC,IAAI;;;;;MAKxCe,UAAU,MAAM,IAAIO,eAAevB,WAAWgB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOnB,OAAOI,IAAI,cAAA,CAAA,KAA2Ce,OAAOjB,MAAG,GACxE,OAAOwB,UAAUC,SAAS,MAAM7B,KAAK4B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACtFA,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","nodemailer","createTransport","SES","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","SES","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/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;EAEAC,MAAOC,WAAqB;AACxB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,OAAQD,WAAqB;AACzB,SAAKV,eAAeU;AACpB,WAAO;EACX;EAEAE,QAASA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AAA;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
|
@@ -38,12 +38,13 @@ interface SMTPConfig extends SMTPConnection.Options {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
interface SESConfig extends SESConnection__default.Options {
|
|
41
|
-
/** is an option that expects an instantiated aws.SES object */
|
|
42
|
-
SES: any;
|
|
43
41
|
/** How many messages per second is allowed to be delivered to SES */
|
|
44
42
|
maxConnections?: number | undefined;
|
|
45
43
|
/** How many parallel connections to allow towards SES */
|
|
46
44
|
sendingRate?: number | undefined;
|
|
45
|
+
region?: string;
|
|
46
|
+
secret: string;
|
|
47
|
+
key: string;
|
|
47
48
|
}
|
|
48
49
|
interface SendMailConfig extends SendmailTransport__default.Options {
|
|
49
50
|
/** path to the sendmail command (defaults to ‘sendmail’) */
|
package/dist/index.d.ts
CHANGED
|
@@ -38,12 +38,13 @@ interface SMTPConfig extends SMTPConnection.Options {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
interface SESConfig extends SESConnection__default.Options {
|
|
41
|
-
/** is an option that expects an instantiated aws.SES object */
|
|
42
|
-
SES: any;
|
|
43
41
|
/** How many messages per second is allowed to be delivered to SES */
|
|
44
42
|
maxConnections?: number | undefined;
|
|
45
43
|
/** How many parallel connections to allow towards SES */
|
|
46
44
|
sendingRate?: number | undefined;
|
|
45
|
+
region?: string;
|
|
46
|
+
secret: string;
|
|
47
|
+
key: string;
|
|
47
48
|
}
|
|
48
49
|
interface SendMailConfig extends SendmailTransport__default.Options {
|
|
49
50
|
/** path to the sendmail command (defaults to ‘sendmail’) */
|
package/dist/index.js
CHANGED
|
@@ -98,14 +98,25 @@ var Mailer = class {
|
|
|
98
98
|
|
|
99
99
|
// src/Drivers/SESDriver.ts
|
|
100
100
|
import nodemailer from "nodemailer";
|
|
101
|
+
import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
|
|
101
102
|
var SESDriver = class {
|
|
102
103
|
static {
|
|
103
104
|
__name(this, "SESDriver");
|
|
104
105
|
}
|
|
105
106
|
transporter;
|
|
106
107
|
constructor(config) {
|
|
108
|
+
const sesClient = new SESv2Client({
|
|
109
|
+
region: config.region,
|
|
110
|
+
credentials: {
|
|
111
|
+
accessKeyId: config.key,
|
|
112
|
+
secretAccessKey: config.secret
|
|
113
|
+
}
|
|
114
|
+
});
|
|
107
115
|
this.transporter = nodemailer.createTransport({
|
|
108
|
-
SES:
|
|
116
|
+
SES: {
|
|
117
|
+
sesClient,
|
|
118
|
+
SendEmailCommand
|
|
119
|
+
},
|
|
109
120
|
maxConnections: config.maxConnections,
|
|
110
121
|
sendingRate: config.sendingRate
|
|
111
122
|
});
|
|
@@ -238,7 +249,9 @@ var Service = class {
|
|
|
238
249
|
* SES configuration with fallback defaults
|
|
239
250
|
*/
|
|
240
251
|
ses: {
|
|
241
|
-
|
|
252
|
+
key: config.get("services.ses.key", ""),
|
|
253
|
+
secret: config.get("services.ses.secret", ""),
|
|
254
|
+
region: config.get("services.ses.region", "us-east-1"),
|
|
242
255
|
maxConnections: config.get("mail.mailers.ses.connections", 10),
|
|
243
256
|
sendingRate: config.get("mail.mailers.ses.rate", 5)
|
|
244
257
|
},
|
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';\n\nexport class SESDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SESConfig) {\n this.transporter = nodemailer.createTransport({\n SES: config.SES,\n maxConnections: config.maxConnections,\n sendingRate: config.sendingRate\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, 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 SES: config.get('mail.mailers.ses.transport', 'ses'),\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,cAAc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;;MAIAa,UAA0B;QACtBC,MAAMlB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMe,SAAS;;;;;MAKXN,KAAK,MAAM,IAAIO,UAAUnB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAImB,WAAWpB,WAAWC,IAAI;;;;;MAK1CoB,KAAK,MAAM,IAAIC,UAAUtB,WAAWC,IAAI;;;;;MAKxCe,UAAU,MAAM,IAAIO,eAAevB,WAAWgB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOnB,OAAOI,IAAI,cAAA,CAAA,KAA2Ce,OAAOjB,MAAG,GACxE,OAAOwB,UAAUC,SAAS,MAAM7B,KAAK4B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACtFA,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","SESDriver","transporter","config","nodemailer","createTransport","SES","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","SES","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/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,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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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": "9.
|
|
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.5.
|
|
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": {
|