@h3ravel/mail 11.0.0 → 11.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.cjs +287 -325
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -106
- package/dist/index.d.ts +117 -106
- package/dist/index.js +260 -290
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,Q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8B,UAAA;MACnD;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"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Stream","SESv2Client","driver: MailDriverContract","edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>","ServiceProvider"],"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 if (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 {\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\n// import { LOGDriver } from '../Drivers/LOGDriver'\nimport { Mailer } from '../Mailer'\n// import { SESDriver } from '../Drivers/SESDriver'\n// import { SMTPDriver } from '../Drivers/SMTPDriver'\n// import { 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,YAAb,MAAqD;CACjD,AAAQ;CAER,YAAY,SAAc;AACtB,OAAK,cAAc,mBAAW,gBAAgB;GAC1C,iBAAiB;GACjB,SAAS;GACZ,CAAC;;CAGN,MAAM,KAAM,SAA0B;AAClC,OAAK,YAAY,SAAS,UAAU,KAAK,SAAS;AAC9C,OAAI,IAAK,OAAM;AACf,WAAQ,IAAI,KAAK,SAAS;AAC1B,WAAQ,IAAI,KAAK,UAAU;AAE3B,OAAI,KAAK,mBAAmBA,eAAO,SAAU,MAAK,QAAQ,KAAK,QAAQ,OAAO;IAEjF;;;;;;ACnBT,IAAa,iBAAb,MAA0D;CACtD,AAAQ;CAER,YAAY,QAAwB;AAChC,OAAK,cAAc,mBAAW,gBAAgB;GAC1C,UAAU;GACV,MAAM,OAAO;GAChB,CAAC;;CAGN,MAAM,KAAM,SAA0B;AAClC,SAAO,MAAM,KAAK,YAAY,SAAS;GACnC,IAAI,QAAQ;GACZ,IAAI,QAAQ;GACZ,KAAK,QAAQ;GACb,SAAS,QAAQ;GACjB,MAAM,QAAQ;GACd,MAAM,QAAQ;GACd,aAAa,QAAQ;GACxB,CAAC;;;;;;AClBV,IAAa,YAAb,MAAqD;CACjD,AAAQ;CAER,YAAY,QAAmB;EAG3B,MAAM,YAAY,IAAIC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D,kBAAkB,OAAO,IAAI,qCAAqC,KAAK;IACvE,mBAAmB,OAAO,IAAI,4BAA4B;IAC1D,OAAO;IACV;GAID,KAAgB;IACZ,KAAK,OAAO,IAAI,oBAAoB,GAAG;IACvC,OAAO,OAAO,IAAI,sBAAsB,GAAG;IAC3C,QAAQ,OAAO,IAAI,uBAAuB,GAAG;IAC7C,QAAQ,OAAO,IAAI,uBAAuB,YAAY;IACtD,gBAAgB,OAAO,IAAI,gCAAgC,GAAG;IAC9D,aAAa,OAAO,IAAI,yBAAyB,EAAE;IACtD;GAID,UAA0B,EACtB,MAAM,OAAO,IAAI,8BAA8B,WAAW,EAC7D;GACJ;;;;EAKD,MAAM,SAAS;GAKX,WAAW,IAAI,UAAU,WAAW,IAAI;GAKxC,YAAY,IAAI,WAAW,WAAW,KAAK;GAK3C,WAAW,IAAI,UAAU,WAAW,KAAK;GAKzC,gBAAgB,IAAI,eAAe,WAAW,SAAS;GAC1D;;;;;AAMD,SAAO,IAAI,QACN,OAAO,OAAO,IAAI,eAAe,KAA4B,OAAO,OAAO,EAC5E,OAAO,UAAU,SAAS,MAAM,KAAK,UAAU,KAAK,CACvD;;;;;;;;;;;;;;AC7ET,IAAa,sBAAb,cAAyCC,+BAAgB;CACrD,OAAc,WAAW;CACzB,WAAY;;;;AAIR,OAAK,IAAI,UAAe,cAAc;AAClC,UAAO,QAAQ,KAAK,KAAK,IAAI;IAC/B;;CAGN,OAAQ"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,119 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from "nodemailer";
|
|
3
|
+
import * as nodemailer_lib_ses_transport0 from "nodemailer/lib/ses-transport";
|
|
4
|
+
import SESConnection from "nodemailer/lib/ses-transport";
|
|
5
|
+
import SMTPConnection from "nodemailer/lib/smtp-connection";
|
|
6
|
+
import * as nodemailer_lib_sendmail_transport0 from "nodemailer/lib/sendmail-transport";
|
|
7
|
+
import SendmailTransport from "nodemailer/lib/sendmail-transport";
|
|
8
|
+
import * as nodemailer_lib_smtp_transport0 from "nodemailer/lib/smtp-transport";
|
|
9
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
9
10
|
|
|
11
|
+
//#region src/Contracts/Mailer.d.ts
|
|
10
12
|
interface DeliveryReport {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
accepted: string[];
|
|
14
|
+
rejected: string[];
|
|
15
|
+
ehlo: string[];
|
|
16
|
+
envelopeTime: number;
|
|
17
|
+
messageTime: number;
|
|
18
|
+
messageSize: number;
|
|
19
|
+
response: string;
|
|
20
|
+
envelope: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
to: string[];
|
|
23
|
+
from: string;
|
|
24
|
+
};
|
|
25
|
+
messageId: string;
|
|
24
26
|
}
|
|
25
27
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
viewPath?: string;
|
|
29
|
+
viewData?: Record<string, any>;
|
|
28
30
|
}
|
|
29
31
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
33
|
+
host?: string | undefined;
|
|
34
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
35
|
+
port?: number | undefined;
|
|
36
|
+
/** defines authentication data */
|
|
37
|
+
auth: {
|
|
38
|
+
user: string;
|
|
39
|
+
pass: string;
|
|
40
|
+
};
|
|
39
41
|
}
|
|
40
|
-
interface SESConfig extends
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
interface SESConfig extends SESConnection.Options {
|
|
43
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
44
|
+
maxConnections?: number | undefined;
|
|
45
|
+
/** How many parallel connections to allow towards SES */
|
|
46
|
+
sendingRate?: number | undefined;
|
|
47
|
+
region?: string;
|
|
48
|
+
secret: string;
|
|
49
|
+
token?: string;
|
|
50
|
+
key: string;
|
|
49
51
|
}
|
|
50
|
-
interface SendMailConfig extends
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
interface SendMailConfig extends SendmailTransport.Options {
|
|
53
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
54
|
+
path?: string | undefined;
|
|
53
55
|
}
|
|
54
56
|
interface MailDriverContract {
|
|
55
|
-
|
|
57
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/Drivers/LOGDriver.d.ts
|
|
58
61
|
declare class LOGDriver implements MailDriverContract {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
private transporter;
|
|
63
|
+
constructor(_config: any);
|
|
64
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/Drivers/SendMailDriver.d.ts
|
|
64
68
|
declare class SendMailDriver implements MailDriverContract {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
private transporter;
|
|
70
|
+
constructor(config: SendMailConfig);
|
|
71
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_sendmail_transport0.SentMessageInfo>;
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/Drivers/SESDriver.d.ts
|
|
70
75
|
declare class SESDriver implements MailDriverContract {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
private transporter;
|
|
77
|
+
constructor(config: SESConfig);
|
|
78
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_ses_transport0.SentMessageInfo>;
|
|
74
79
|
}
|
|
75
|
-
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/Drivers/SMTPDriver.d.ts
|
|
76
82
|
declare class SMTPDriver implements MailDriverContract {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
private transporter;
|
|
84
|
+
constructor(config: SMTPConfig);
|
|
85
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport0.SentMessageInfo>;
|
|
80
86
|
}
|
|
81
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/Mailable.d.ts
|
|
82
89
|
declare abstract class Mailable {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
protected toAddress?: string;
|
|
91
|
+
protected ccAddresses?: string[];
|
|
92
|
+
protected bccAddresses?: string[];
|
|
93
|
+
protected subjectText?: string;
|
|
94
|
+
protected htmlContent?: string;
|
|
95
|
+
protected textContent?: string;
|
|
96
|
+
protected viewPath?: string;
|
|
97
|
+
protected viewData?: Record<string, any>;
|
|
98
|
+
protected attachmentsList?: SendMailOptions['attachments'];
|
|
99
|
+
to(address: string): this;
|
|
100
|
+
cc(...addresses: string[]): this;
|
|
101
|
+
bcc(...addresses: string[]): this;
|
|
102
|
+
subject(subject: string): this;
|
|
103
|
+
html(html: string): this;
|
|
104
|
+
text(text: string): this;
|
|
105
|
+
view(path: string, data?: Record<string, any>): this;
|
|
106
|
+
attach(filename: string, filePath: string): this;
|
|
107
|
+
/**
|
|
108
|
+
* Child classes should define build() like in Laravel
|
|
109
|
+
*/
|
|
110
|
+
abstract build(): Promise<this> | this;
|
|
111
|
+
/**
|
|
112
|
+
* Called internally by Mailer
|
|
113
|
+
*/
|
|
114
|
+
getMessageOptions(): SendMailOptions;
|
|
108
115
|
}
|
|
109
|
-
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/Mailer.d.ts
|
|
110
118
|
declare class Mailer {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
private driver;
|
|
120
|
+
private edgeRenderer;
|
|
121
|
+
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
122
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
115
123
|
}
|
|
116
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/Providers/MailServiceProvider.d.ts
|
|
117
126
|
/**
|
|
118
127
|
* Mail delivery setup.
|
|
119
128
|
*
|
|
@@ -123,22 +132,24 @@ declare class Mailer {
|
|
|
123
132
|
*
|
|
124
133
|
*/
|
|
125
134
|
declare class MailServiceProvider extends ServiceProvider {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
static priority: number;
|
|
136
|
+
register(): void;
|
|
137
|
+
boot(): void;
|
|
129
138
|
}
|
|
130
|
-
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/Service.d.ts
|
|
131
141
|
/**
|
|
132
142
|
* Service class to initialize and configure the mailer service
|
|
133
143
|
*/
|
|
134
144
|
declare class Service {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Initializes the mailer service with the given application instance
|
|
147
|
+
*
|
|
148
|
+
* @param app
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
static init(app: Application): Mailer;
|
|
142
152
|
}
|
|
143
|
-
|
|
144
|
-
export {
|
|
153
|
+
//#endregion
|
|
154
|
+
export { DeliveryReport, LOGDriver, MailDriverContract, MailServiceProvider, Mailable, Mailer, SESConfig, SESDriver, SMTPConfig, SMTPDriver, SendMailConfig, SendMailDriver, SendMailOptions, Service };
|
|
155
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,119 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
1
|
+
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from "nodemailer";
|
|
3
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
4
|
+
import * as nodemailer_lib_ses_transport0 from "nodemailer/lib/ses-transport";
|
|
5
|
+
import SESConnection from "nodemailer/lib/ses-transport";
|
|
6
|
+
import SMTPConnection from "nodemailer/lib/smtp-connection";
|
|
7
|
+
import * as nodemailer_lib_sendmail_transport0 from "nodemailer/lib/sendmail-transport";
|
|
8
|
+
import SendmailTransport from "nodemailer/lib/sendmail-transport";
|
|
9
|
+
import * as nodemailer_lib_smtp_transport0 from "nodemailer/lib/smtp-transport";
|
|
9
10
|
|
|
11
|
+
//#region src/Contracts/Mailer.d.ts
|
|
10
12
|
interface DeliveryReport {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
accepted: string[];
|
|
14
|
+
rejected: string[];
|
|
15
|
+
ehlo: string[];
|
|
16
|
+
envelopeTime: number;
|
|
17
|
+
messageTime: number;
|
|
18
|
+
messageSize: number;
|
|
19
|
+
response: string;
|
|
20
|
+
envelope: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
to: string[];
|
|
23
|
+
from: string;
|
|
24
|
+
};
|
|
25
|
+
messageId: string;
|
|
24
26
|
}
|
|
25
27
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
viewPath?: string;
|
|
29
|
+
viewData?: Record<string, any>;
|
|
28
30
|
}
|
|
29
31
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
33
|
+
host?: string | undefined;
|
|
34
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
35
|
+
port?: number | undefined;
|
|
36
|
+
/** defines authentication data */
|
|
37
|
+
auth: {
|
|
38
|
+
user: string;
|
|
39
|
+
pass: string;
|
|
40
|
+
};
|
|
39
41
|
}
|
|
40
|
-
interface SESConfig extends
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
interface SESConfig extends SESConnection.Options {
|
|
43
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
44
|
+
maxConnections?: number | undefined;
|
|
45
|
+
/** How many parallel connections to allow towards SES */
|
|
46
|
+
sendingRate?: number | undefined;
|
|
47
|
+
region?: string;
|
|
48
|
+
secret: string;
|
|
49
|
+
token?: string;
|
|
50
|
+
key: string;
|
|
49
51
|
}
|
|
50
|
-
interface SendMailConfig extends
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
interface SendMailConfig extends SendmailTransport.Options {
|
|
53
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
54
|
+
path?: string | undefined;
|
|
53
55
|
}
|
|
54
56
|
interface MailDriverContract {
|
|
55
|
-
|
|
57
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/Drivers/LOGDriver.d.ts
|
|
58
61
|
declare class LOGDriver implements MailDriverContract {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
private transporter;
|
|
63
|
+
constructor(_config: any);
|
|
64
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/Drivers/SendMailDriver.d.ts
|
|
64
68
|
declare class SendMailDriver implements MailDriverContract {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
private transporter;
|
|
70
|
+
constructor(config: SendMailConfig);
|
|
71
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_sendmail_transport0.SentMessageInfo>;
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/Drivers/SESDriver.d.ts
|
|
70
75
|
declare class SESDriver implements MailDriverContract {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
private transporter;
|
|
77
|
+
constructor(config: SESConfig);
|
|
78
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_ses_transport0.SentMessageInfo>;
|
|
74
79
|
}
|
|
75
|
-
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/Drivers/SMTPDriver.d.ts
|
|
76
82
|
declare class SMTPDriver implements MailDriverContract {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
private transporter;
|
|
84
|
+
constructor(config: SMTPConfig);
|
|
85
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport0.SentMessageInfo>;
|
|
80
86
|
}
|
|
81
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/Mailable.d.ts
|
|
82
89
|
declare abstract class Mailable {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
protected toAddress?: string;
|
|
91
|
+
protected ccAddresses?: string[];
|
|
92
|
+
protected bccAddresses?: string[];
|
|
93
|
+
protected subjectText?: string;
|
|
94
|
+
protected htmlContent?: string;
|
|
95
|
+
protected textContent?: string;
|
|
96
|
+
protected viewPath?: string;
|
|
97
|
+
protected viewData?: Record<string, any>;
|
|
98
|
+
protected attachmentsList?: SendMailOptions['attachments'];
|
|
99
|
+
to(address: string): this;
|
|
100
|
+
cc(...addresses: string[]): this;
|
|
101
|
+
bcc(...addresses: string[]): this;
|
|
102
|
+
subject(subject: string): this;
|
|
103
|
+
html(html: string): this;
|
|
104
|
+
text(text: string): this;
|
|
105
|
+
view(path: string, data?: Record<string, any>): this;
|
|
106
|
+
attach(filename: string, filePath: string): this;
|
|
107
|
+
/**
|
|
108
|
+
* Child classes should define build() like in Laravel
|
|
109
|
+
*/
|
|
110
|
+
abstract build(): Promise<this> | this;
|
|
111
|
+
/**
|
|
112
|
+
* Called internally by Mailer
|
|
113
|
+
*/
|
|
114
|
+
getMessageOptions(): SendMailOptions;
|
|
108
115
|
}
|
|
109
|
-
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/Mailer.d.ts
|
|
110
118
|
declare class Mailer {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
private driver;
|
|
120
|
+
private edgeRenderer;
|
|
121
|
+
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
122
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
115
123
|
}
|
|
116
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/Providers/MailServiceProvider.d.ts
|
|
117
126
|
/**
|
|
118
127
|
* Mail delivery setup.
|
|
119
128
|
*
|
|
@@ -123,22 +132,24 @@ declare class Mailer {
|
|
|
123
132
|
*
|
|
124
133
|
*/
|
|
125
134
|
declare class MailServiceProvider extends ServiceProvider {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
static priority: number;
|
|
136
|
+
register(): void;
|
|
137
|
+
boot(): void;
|
|
129
138
|
}
|
|
130
|
-
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/Service.d.ts
|
|
131
141
|
/**
|
|
132
142
|
* Service class to initialize and configure the mailer service
|
|
133
143
|
*/
|
|
134
144
|
declare class Service {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Initializes the mailer service with the given application instance
|
|
147
|
+
*
|
|
148
|
+
* @param app
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
static init(app: Application): Mailer;
|
|
142
152
|
}
|
|
143
|
-
|
|
144
|
-
export {
|
|
153
|
+
//#endregion
|
|
154
|
+
export { DeliveryReport, LOGDriver, MailDriverContract, MailServiceProvider, Mailable, Mailer, SESConfig, SESDriver, SMTPConfig, SMTPDriver, SendMailConfig, SendMailDriver, SendMailOptions, Service };
|
|
155
|
+
//# sourceMappingURL=index.d.ts.map
|