@h3ravel/mail 10.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.cjs +291 -331
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -116
- package/dist/index.d.ts +126 -116
- package/dist/index.js +265 -297
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
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';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport class SESDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SESConfig) {\n\n // 1. Configure the AWS SDK client (uses default credential chain if omitted)\n const sesClient = new SESv2Client({\n region: config.region,\n credentials: {\n accessKeyId: config.key,\n sessionToken: config.token,\n secretAccessKey: config.secret\n }\n });\n\n // 2. Create a Nodemailer transport that points at SES\n this.transporter = nodemailer.createTransport({\n SES: { sesClient, SendEmailCommand },\n maxConnections: config.maxConnections,\n sendingRate: config.sendingRate\n });\n }\n\n async send (options: SendMailOptions) {\n // 3. Send the message\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';\n\nexport class SMTPDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SMTPConfig) {\n this.transporter = nodemailer.createTransport({\n host: config.host,\n port: config.port,\n secure: config.port === 465, // auto decide based on port\n auth: {\n user: config.auth.user,\n pass: config.auth.pass\n }\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract } from '../Contracts/Mailer';\nimport Stream from 'stream';\n\nexport class LOGDriver implements MailDriverContract {\n private transporter\n\n constructor(_config: any) {\n this.transporter = nodemailer.createTransport({\n streamTransport: true,\n newline: \"unix\",\n });\n }\n\n async send (options: SendMailOptions) {\n this.transporter.sendMail(options, (err, info) => {\n if (err) throw err;\n console.log(info.envelope);\n console.log(info.messageId);\n // Pipe the raw RFC 822 message to STDOUT\n info.message instanceof Stream.Readable && info.message.pipe(process.stdout);\n }\n );\n }\n}\n","import nodemailer, { type SendMailOptions } from 'nodemailer';\n\nimport { MailDriverContract, SendMailConfig } from '../Contracts/Mailer';\n\nexport class SendMailDriver implements MailDriverContract {\n private transporter;\n\n constructor(config: SendMailConfig) {\n this.transporter = nodemailer.createTransport({\n sendmail: true,\n path: config.path,\n });\n }\n\n async send (options: SendMailOptions) {\n return await this.transporter.sendMail({\n to: options.to,\n cc: options.cc,\n bcc: options.bcc,\n subject: options.subject,\n html: options.html,\n text: options.text,\n attachments: options.attachments\n });\n }\n}\n","import { Application } from \"@h3ravel/core\";\nimport { SendMailConfig, SESConfig, SMTPConfig } from \"./Contracts/Mailer\";\nimport { SESDriver } from \"./Drivers/SESDriver\";\nimport { SMTPDriver } from \"./Drivers/SMTPDriver\";\nimport { LOGDriver } from \"./Drivers/LOGDriver\";\nimport { SendMailDriver } from \"./Drivers/SendMailDriver\";\nimport { Mailer } from \"./Mailer\";\n\n/**\n * Service class to initialize and configure the mailer service\n */\nexport class Service {\n /**\n * Initializes the mailer service with the given application instance\n * \n * @param app \n * @returns \n */\n static init (app: Application) {\n /**\n * Resolve the view and config services from the container\n */\n const view = app.make('view');\n const config = app.make('config');\n\n /**\n * Configure mailer settings for different drivers\n */\n const mailConfig = {\n /**\n * SMTP configuration with fallback defaults\n */\n smtp: <SMTPConfig>{\n host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),\n port: Number(config.get('mail.mailers.smtp.port', 2525)),\n auth: {\n user: config.get('mail.mailers.smtp.username', ''),\n pass: config.get('mail.mailers.smtp.password', ''),\n },\n opportunisticTLS: config.get('mail.mail气的mailers.smtp.encryption') === 'tls',\n connectionTimeout: config.get('mail.mailers.smtp.timeout'),\n debug: false,\n },\n /**\n * SES configuration with fallback defaults\n */\n ses: <SESConfig>{\n key: config.get('services.ses.key', ''),\n token: config.get('services.ses.token', ''),\n secret: config.get('services.ses.secret', ''),\n region: config.get('services.ses.region', 'us-east-1'),\n maxConnections: config.get('mail.mailers.ses.connections', 10),\n sendingRate: config.get('mail.mailers.ses.rate', 5),\n },\n /**\n * Sendmail configuration with fallback default path\n */\n sendmail: <SendMailConfig>{\n path: config.get('mail.mailers.sendmail.path', 'sendmail'),\n },\n };\n\n /**\n * Define available mail drivers\n */\n const driver = {\n /**\n * SES driver factory\n * @returns \n */\n ses: () => new SESDriver(mailConfig.ses),\n /**\n * SMTP driver factory\n * @returns \n */\n smtp: () => new SMTPDriver(mailConfig.smtp),\n /**\n * LOG driver factory for debugging\n * @returns \n */\n log: () => new LOGDriver(mailConfig.smtp),\n /**\n * Sendmail driver factory\n * @returns \n */\n sendmail: () => new SendMailDriver(mailConfig.sendmail),\n };\n\n /**\n * Initialize Mailer with the selected driver (default to SMTP if not specified)\n * and a view rendering function\n */\n return new Mailer(\n (driver[config.get('mail.default') as keyof typeof driver] ?? driver.smtp)(),\n async (viewPath, data) => await view(viewPath, data)\n );\n }\n}\n","import { SESConfig, SMTPConfig, SendMailConfig } from '../Contracts/Mailer';\n\nimport { LOGDriver } from '../Drivers/LOGDriver';\nimport { Mailer } from '../Mailer';\nimport { SESDriver } from '../Drivers/SESDriver';\nimport { SMTPDriver } from '../Drivers/SMTPDriver';\nimport { SendMailDriver } from '../Drivers/SendMailDriver';\nimport { Service } from '../Service';\nimport { ServiceProvider } from '@h3ravel/core';\n\n/**\n * Mail delivery setup.\n * \n * Bind Mailer service.\n * Load mail drivers (SMTP, SES, etc.).\n * Register Mail facade.\n * \n */\nexport class MailServiceProvider extends ServiceProvider {\n public static priority = 990;\n register () {\n /**\n * Register Mailer instance\n */\n this.app.singleton<any>(Mailer, () => {\n return Service.init(this.app)\n });\n }\n\n boot () {\n /**\n * Add logic here for global mail \"from\" address and others\n */\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;ACEO,IAAeA,WAAf,MAAeA;EAAtB,OAAsBA;;;EACRC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEVC,GAAIC,SAAiB;AACjB,SAAKV,YAAYU;AACjB,WAAO;EACX;EAEAC,MAAOC,WAAqB;AACxB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,OAAQD,WAAqB;AACzB,SAAKV,eAAeU;AACpB,WAAO;EACX;EAEAE,QAASA,SAAiB;AACtB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMA,MAAc;AAChB,SAAKX,cAAcW;AACnB,WAAO;EACX;EAEAC,KAAMC,MAAcC,OAA4B,CAAC,GAAG;AAChD,SAAKb,WAAWY;AAChB,SAAKX,WAAWY;AAChB,WAAO;EACX;EAEAC,OAAQC,UAA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ACtBC,MAAMrB,OAAOI,IAAI,8BAA8B,UAAA;MACnD;IACJ;AAKA,UAAMkB,SAAS;;;;;MAKXT,KAAK,MAAM,IAAIU,UAAUtB,WAAWY,GAAG;;;;;MAKvCX,MAAM,MAAM,IAAIsB,WAAWvB,WAAWC,IAAI;;;;;MAK1CuB,KAAK,MAAM,IAAIC,UAAUzB,WAAWC,IAAI;;;;;MAKxCkB,UAAU,MAAM,IAAIO,eAAe1B,WAAWmB,QAAQ;IAC1D;AAMA,WAAO,IAAIQ,QACNN,OAAOtB,OAAOI,IAAI,cAAA,CAAA,KAA2CkB,OAAOpB,MAAG,GACxE,OAAO2B,UAAUC,SAAS,MAAMhC,KAAK+B,UAAUC,IAAAA,CAAAA;EAEvD;AACJ;;;ACzFA,kBAAgC;AAUzB,IAAMC,sBAAN,cAAkCC,4BAAAA;EAfzC,OAeyCA;;;EACrC,OAAcC,WAAW;EACzBC,WAAY;AAIR,SAAKC,IAAIC,UAAeC,QAAQ,MAAA;AAC5B,aAAOC,QAAQC,KAAK,KAAKJ,GAAG;IAChC,CAAA;EACJ;EAEAK,OAAQ;EAIR;AACJ;","names":["Mailable","toAddress","ccAddresses","bccAddresses","subjectText","htmlContent","textContent","viewPath","viewData","attachmentsList","to","address","cc","addresses","bcc","subject","html","text","view","path","data","attach","filename","filePath","push","getMessageOptions","attachments","Mailer","driver","edgeRenderer","send","mailable","build","options","getMessageOptions","viewPath","html","viewData","error","SESDriver","transporter","config","sesClient","SESv2Client","region","credentials","accessKeyId","key","sessionToken","token","secretAccessKey","secret","nodemailer","createTransport","SES","SendEmailCommand","maxConnections","sendingRate","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","import_nodemailer","SMTPDriver","transporter","config","nodemailer","createTransport","host","port","secure","auth","user","pass","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","import_nodemailer","LOGDriver","transporter","_config","nodemailer","createTransport","streamTransport","newline","send","options","sendMail","err","info","console","log","envelope","messageId","message","Stream","Readable","pipe","process","stdout","import_nodemailer","SendMailDriver","transporter","config","nodemailer","createTransport","sendmail","path","send","options","sendMail","to","cc","bcc","subject","html","text","attachments","Service","init","app","view","make","config","mailConfig","smtp","host","get","port","Number","auth","user","pass","opportunisticTLS","connectionTimeout","debug","ses","key","token","secret","region","maxConnections","sendingRate","sendmail","path","driver","SESDriver","SMTPDriver","log","LOGDriver","SendMailDriver","Mailer","viewPath","data","MailServiceProvider","ServiceProvider","priority","register","app","singleton","Mailer","Service","init","boot"]}
|
|
1
|
+
{"version":3,"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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAK,mBAAmBA,eAAO,YAAY,KAAK,QAAQ,KAAK,QAAQ,OAAO;IAE/E;;;;;;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,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O,IAAI,8BAA8B,GAAG;KAClD,MAAM,OAAO,IAAI,8BAA8B,GAAG;KACrD;IACD,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,132 +1,127 @@
|
|
|
1
|
-
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import SMTPConnection from
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from "nodemailer";
|
|
2
|
+
import * as nodemailer_lib_ses_transport0 from "nodemailer/lib/ses-transport";
|
|
3
|
+
import SESConnection from "nodemailer/lib/ses-transport";
|
|
4
|
+
import SMTPConnection from "nodemailer/lib/smtp-connection";
|
|
5
|
+
import * as nodemailer_lib_sendmail_transport0 from "nodemailer/lib/sendmail-transport";
|
|
6
|
+
import SendmailTransport from "nodemailer/lib/sendmail-transport";
|
|
7
|
+
import * as nodemailer_lib_smtp_transport0 from "nodemailer/lib/smtp-transport";
|
|
8
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
9
9
|
|
|
10
|
+
//#region src/Contracts/Mailer.d.ts
|
|
10
11
|
interface DeliveryReport {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
accepted: string[];
|
|
13
|
+
rejected: string[];
|
|
14
|
+
ehlo: string[];
|
|
15
|
+
envelopeTime: number;
|
|
16
|
+
messageTime: number;
|
|
17
|
+
messageSize: number;
|
|
18
|
+
response: string;
|
|
19
|
+
envelope: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
to: string[];
|
|
22
|
+
from: string;
|
|
23
|
+
};
|
|
24
|
+
messageId: string;
|
|
24
25
|
}
|
|
25
26
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
viewPath?: string;
|
|
28
|
+
viewData?: Record<string, any>;
|
|
28
29
|
}
|
|
29
30
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
32
|
+
host?: string | undefined;
|
|
33
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
34
|
+
port?: number | undefined;
|
|
35
|
+
/** defines authentication data */
|
|
36
|
+
auth: {
|
|
37
|
+
user: string;
|
|
38
|
+
pass: string;
|
|
39
|
+
};
|
|
39
40
|
}
|
|
40
|
-
interface SESConfig extends
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
interface SESConfig extends SESConnection.Options {
|
|
42
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
43
|
+
maxConnections?: number | undefined;
|
|
44
|
+
/** How many parallel connections to allow towards SES */
|
|
45
|
+
sendingRate?: number | undefined;
|
|
46
|
+
region?: string;
|
|
47
|
+
secret: string;
|
|
48
|
+
token?: string;
|
|
49
|
+
key: string;
|
|
49
50
|
}
|
|
50
|
-
interface SendMailConfig extends
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
interface SendMailConfig extends SendmailTransport.Options {
|
|
52
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
53
|
+
path?: string | undefined;
|
|
53
54
|
}
|
|
54
55
|
interface MailDriverContract {
|
|
55
|
-
|
|
56
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
protected toAddress?: string;
|
|
60
|
-
protected ccAddresses?: string[];
|
|
61
|
-
protected bccAddresses?: string[];
|
|
62
|
-
protected subjectText?: string;
|
|
63
|
-
protected htmlContent?: string;
|
|
64
|
-
protected textContent?: string;
|
|
65
|
-
protected viewPath?: string;
|
|
66
|
-
protected viewData?: Record<string, any>;
|
|
67
|
-
protected attachmentsList?: SendMailOptions['attachments'];
|
|
68
|
-
to(address: string): this;
|
|
69
|
-
cc(...addresses: string[]): this;
|
|
70
|
-
bcc(...addresses: string[]): this;
|
|
71
|
-
subject(subject: string): this;
|
|
72
|
-
html(html: string): this;
|
|
73
|
-
text(text: string): this;
|
|
74
|
-
view(path: string, data?: Record<string, any>): this;
|
|
75
|
-
attach(filename: string, filePath: string): this;
|
|
76
|
-
/**
|
|
77
|
-
* Child classes should define build() like in Laravel
|
|
78
|
-
*/
|
|
79
|
-
abstract build(): Promise<this> | this;
|
|
80
|
-
/**
|
|
81
|
-
* Called internally by Mailer
|
|
82
|
-
*/
|
|
83
|
-
getMessageOptions(): SendMailOptions;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare class Mailer {
|
|
87
|
-
private driver;
|
|
88
|
-
private edgeRenderer;
|
|
89
|
-
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
90
|
-
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Service class to initialize and configure the mailer service
|
|
95
|
-
*/
|
|
96
|
-
declare class Service {
|
|
97
|
-
/**
|
|
98
|
-
* Initializes the mailer service with the given application instance
|
|
99
|
-
*
|
|
100
|
-
* @param app
|
|
101
|
-
* @returns
|
|
102
|
-
*/
|
|
103
|
-
static init(app: Application): Mailer;
|
|
104
|
-
}
|
|
105
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/Drivers/LOGDriver.d.ts
|
|
106
60
|
declare class LOGDriver implements MailDriverContract {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
61
|
+
private transporter;
|
|
62
|
+
constructor(_config: any);
|
|
63
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
110
64
|
}
|
|
111
|
-
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/Drivers/SendMailDriver.d.ts
|
|
67
|
+
declare class SendMailDriver implements MailDriverContract {
|
|
68
|
+
private transporter;
|
|
69
|
+
constructor(config: SendMailConfig);
|
|
70
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_sendmail_transport0.SentMessageInfo>;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/Drivers/SESDriver.d.ts
|
|
112
74
|
declare class SESDriver implements MailDriverContract {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
private transporter;
|
|
76
|
+
constructor(config: SESConfig);
|
|
77
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_ses_transport0.SentMessageInfo>;
|
|
116
78
|
}
|
|
117
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/Drivers/SMTPDriver.d.ts
|
|
118
81
|
declare class SMTPDriver implements MailDriverContract {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
82
|
+
private transporter;
|
|
83
|
+
constructor(config: SMTPConfig);
|
|
84
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport0.SentMessageInfo>;
|
|
122
85
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/Mailable.d.ts
|
|
88
|
+
declare abstract class Mailable {
|
|
89
|
+
protected toAddress?: string;
|
|
90
|
+
protected ccAddresses?: string[];
|
|
91
|
+
protected bccAddresses?: string[];
|
|
92
|
+
protected subjectText?: string;
|
|
93
|
+
protected htmlContent?: string;
|
|
94
|
+
protected textContent?: string;
|
|
95
|
+
protected viewPath?: string;
|
|
96
|
+
protected viewData?: Record<string, any>;
|
|
97
|
+
protected attachmentsList?: SendMailOptions['attachments'];
|
|
98
|
+
to(address: string): this;
|
|
99
|
+
cc(...addresses: string[]): this;
|
|
100
|
+
bcc(...addresses: string[]): this;
|
|
101
|
+
subject(subject: string): this;
|
|
102
|
+
html(html: string): this;
|
|
103
|
+
text(text: string): this;
|
|
104
|
+
view(path: string, data?: Record<string, any>): this;
|
|
105
|
+
attach(filename: string, filePath: string): this;
|
|
106
|
+
/**
|
|
107
|
+
* Child classes should define build() like in Laravel
|
|
108
|
+
*/
|
|
109
|
+
abstract build(): Promise<this> | this;
|
|
110
|
+
/**
|
|
111
|
+
* Called internally by Mailer
|
|
112
|
+
*/
|
|
113
|
+
getMessageOptions(): SendMailOptions;
|
|
128
114
|
}
|
|
129
|
-
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/Mailer.d.ts
|
|
117
|
+
declare class Mailer {
|
|
118
|
+
private driver;
|
|
119
|
+
private edgeRenderer;
|
|
120
|
+
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
121
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/Providers/MailServiceProvider.d.ts
|
|
130
125
|
/**
|
|
131
126
|
* Mail delivery setup.
|
|
132
127
|
*
|
|
@@ -136,9 +131,24 @@ declare class SendMailDriver implements MailDriverContract {
|
|
|
136
131
|
*
|
|
137
132
|
*/
|
|
138
133
|
declare class MailServiceProvider extends ServiceProvider {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
static priority: number;
|
|
135
|
+
register(): void;
|
|
136
|
+
boot(): void;
|
|
142
137
|
}
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/Service.d.ts
|
|
140
|
+
/**
|
|
141
|
+
* Service class to initialize and configure the mailer service
|
|
142
|
+
*/
|
|
143
|
+
declare class Service {
|
|
144
|
+
/**
|
|
145
|
+
* Initializes the mailer service with the given application instance
|
|
146
|
+
*
|
|
147
|
+
* @param app
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
static init(app: Application): Mailer;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { DeliveryReport, LOGDriver, MailDriverContract, MailServiceProvider, Mailable, Mailer, SESConfig, SESDriver, SMTPConfig, SMTPDriver, SendMailConfig, SendMailDriver, SendMailOptions, Service };
|
|
154
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,127 @@
|
|
|
1
|
-
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as
|
|
1
|
+
import { SendMailOptions as SendMailOptions$1, SentMessageInfo } from "nodemailer";
|
|
2
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
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
9
|
|
|
10
|
+
//#region src/Contracts/Mailer.d.ts
|
|
10
11
|
interface DeliveryReport {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
accepted: string[];
|
|
13
|
+
rejected: string[];
|
|
14
|
+
ehlo: string[];
|
|
15
|
+
envelopeTime: number;
|
|
16
|
+
messageTime: number;
|
|
17
|
+
messageSize: number;
|
|
18
|
+
response: string;
|
|
19
|
+
envelope: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
to: string[];
|
|
22
|
+
from: string;
|
|
23
|
+
};
|
|
24
|
+
messageId: string;
|
|
24
25
|
}
|
|
25
26
|
interface SendMailOptions extends SendMailOptions$1 {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
viewPath?: string;
|
|
28
|
+
viewData?: Record<string, any>;
|
|
28
29
|
}
|
|
29
30
|
interface SMTPConfig extends SMTPConnection.Options {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
/** the hostname or IP address to connect to (defaults to ‘localhost’) */
|
|
32
|
+
host?: string | undefined;
|
|
33
|
+
/** the port to connect to (defaults to 25 or 465) */
|
|
34
|
+
port?: number | undefined;
|
|
35
|
+
/** defines authentication data */
|
|
36
|
+
auth: {
|
|
37
|
+
user: string;
|
|
38
|
+
pass: string;
|
|
39
|
+
};
|
|
39
40
|
}
|
|
40
|
-
interface SESConfig extends
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
interface SESConfig extends SESConnection.Options {
|
|
42
|
+
/** How many messages per second is allowed to be delivered to SES */
|
|
43
|
+
maxConnections?: number | undefined;
|
|
44
|
+
/** How many parallel connections to allow towards SES */
|
|
45
|
+
sendingRate?: number | undefined;
|
|
46
|
+
region?: string;
|
|
47
|
+
secret: string;
|
|
48
|
+
token?: string;
|
|
49
|
+
key: string;
|
|
49
50
|
}
|
|
50
|
-
interface SendMailConfig extends
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
interface SendMailConfig extends SendmailTransport.Options {
|
|
52
|
+
/** path to the sendmail command (defaults to ‘sendmail’) */
|
|
53
|
+
path?: string | undefined;
|
|
53
54
|
}
|
|
54
55
|
interface MailDriverContract {
|
|
55
|
-
|
|
56
|
+
send(options: SendMailOptions$1): Promise<DeliveryReport | SentMessageInfo | undefined | void>;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
protected toAddress?: string;
|
|
60
|
-
protected ccAddresses?: string[];
|
|
61
|
-
protected bccAddresses?: string[];
|
|
62
|
-
protected subjectText?: string;
|
|
63
|
-
protected htmlContent?: string;
|
|
64
|
-
protected textContent?: string;
|
|
65
|
-
protected viewPath?: string;
|
|
66
|
-
protected viewData?: Record<string, any>;
|
|
67
|
-
protected attachmentsList?: SendMailOptions['attachments'];
|
|
68
|
-
to(address: string): this;
|
|
69
|
-
cc(...addresses: string[]): this;
|
|
70
|
-
bcc(...addresses: string[]): this;
|
|
71
|
-
subject(subject: string): this;
|
|
72
|
-
html(html: string): this;
|
|
73
|
-
text(text: string): this;
|
|
74
|
-
view(path: string, data?: Record<string, any>): this;
|
|
75
|
-
attach(filename: string, filePath: string): this;
|
|
76
|
-
/**
|
|
77
|
-
* Child classes should define build() like in Laravel
|
|
78
|
-
*/
|
|
79
|
-
abstract build(): Promise<this> | this;
|
|
80
|
-
/**
|
|
81
|
-
* Called internally by Mailer
|
|
82
|
-
*/
|
|
83
|
-
getMessageOptions(): SendMailOptions;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare class Mailer {
|
|
87
|
-
private driver;
|
|
88
|
-
private edgeRenderer;
|
|
89
|
-
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
90
|
-
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Service class to initialize and configure the mailer service
|
|
95
|
-
*/
|
|
96
|
-
declare class Service {
|
|
97
|
-
/**
|
|
98
|
-
* Initializes the mailer service with the given application instance
|
|
99
|
-
*
|
|
100
|
-
* @param app
|
|
101
|
-
* @returns
|
|
102
|
-
*/
|
|
103
|
-
static init(app: Application): Mailer;
|
|
104
|
-
}
|
|
105
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/Drivers/LOGDriver.d.ts
|
|
106
60
|
declare class LOGDriver implements MailDriverContract {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
61
|
+
private transporter;
|
|
62
|
+
constructor(_config: any);
|
|
63
|
+
send(options: SendMailOptions$1): Promise<void>;
|
|
110
64
|
}
|
|
111
|
-
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/Drivers/SendMailDriver.d.ts
|
|
67
|
+
declare class SendMailDriver implements MailDriverContract {
|
|
68
|
+
private transporter;
|
|
69
|
+
constructor(config: SendMailConfig);
|
|
70
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_sendmail_transport0.SentMessageInfo>;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/Drivers/SESDriver.d.ts
|
|
112
74
|
declare class SESDriver implements MailDriverContract {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
private transporter;
|
|
76
|
+
constructor(config: SESConfig);
|
|
77
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_ses_transport0.SentMessageInfo>;
|
|
116
78
|
}
|
|
117
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/Drivers/SMTPDriver.d.ts
|
|
118
81
|
declare class SMTPDriver implements MailDriverContract {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
82
|
+
private transporter;
|
|
83
|
+
constructor(config: SMTPConfig);
|
|
84
|
+
send(options: SendMailOptions$1): Promise<nodemailer_lib_smtp_transport0.SentMessageInfo>;
|
|
122
85
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/Mailable.d.ts
|
|
88
|
+
declare abstract class Mailable {
|
|
89
|
+
protected toAddress?: string;
|
|
90
|
+
protected ccAddresses?: string[];
|
|
91
|
+
protected bccAddresses?: string[];
|
|
92
|
+
protected subjectText?: string;
|
|
93
|
+
protected htmlContent?: string;
|
|
94
|
+
protected textContent?: string;
|
|
95
|
+
protected viewPath?: string;
|
|
96
|
+
protected viewData?: Record<string, any>;
|
|
97
|
+
protected attachmentsList?: SendMailOptions['attachments'];
|
|
98
|
+
to(address: string): this;
|
|
99
|
+
cc(...addresses: string[]): this;
|
|
100
|
+
bcc(...addresses: string[]): this;
|
|
101
|
+
subject(subject: string): this;
|
|
102
|
+
html(html: string): this;
|
|
103
|
+
text(text: string): this;
|
|
104
|
+
view(path: string, data?: Record<string, any>): this;
|
|
105
|
+
attach(filename: string, filePath: string): this;
|
|
106
|
+
/**
|
|
107
|
+
* Child classes should define build() like in Laravel
|
|
108
|
+
*/
|
|
109
|
+
abstract build(): Promise<this> | this;
|
|
110
|
+
/**
|
|
111
|
+
* Called internally by Mailer
|
|
112
|
+
*/
|
|
113
|
+
getMessageOptions(): SendMailOptions;
|
|
128
114
|
}
|
|
129
|
-
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/Mailer.d.ts
|
|
117
|
+
declare class Mailer {
|
|
118
|
+
private driver;
|
|
119
|
+
private edgeRenderer;
|
|
120
|
+
constructor(driver: MailDriverContract, edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>);
|
|
121
|
+
send(mailable: Mailable): Promise<DeliveryReport | undefined | void>;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/Providers/MailServiceProvider.d.ts
|
|
130
125
|
/**
|
|
131
126
|
* Mail delivery setup.
|
|
132
127
|
*
|
|
@@ -136,9 +131,24 @@ declare class SendMailDriver implements MailDriverContract {
|
|
|
136
131
|
*
|
|
137
132
|
*/
|
|
138
133
|
declare class MailServiceProvider extends ServiceProvider {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
static priority: number;
|
|
135
|
+
register(): void;
|
|
136
|
+
boot(): void;
|
|
142
137
|
}
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/Service.d.ts
|
|
140
|
+
/**
|
|
141
|
+
* Service class to initialize and configure the mailer service
|
|
142
|
+
*/
|
|
143
|
+
declare class Service {
|
|
144
|
+
/**
|
|
145
|
+
* Initializes the mailer service with the given application instance
|
|
146
|
+
*
|
|
147
|
+
* @param app
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
static init(app: Application): Mailer;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { DeliveryReport, LOGDriver, MailDriverContract, MailServiceProvider, Mailable, Mailer, SESConfig, SESDriver, SMTPConfig, SMTPDriver, SendMailConfig, SendMailDriver, SendMailOptions, Service };
|
|
154
|
+
//# sourceMappingURL=index.d.ts.map
|