UNPKG

@tanayvk/mailer

Version:

@adonisjs/mail without @adonisjs/core dependency.

56 lines (55 loc) 2.14 kB
import type { EmitterLike } from './emitter_type.ts'; import { Mailer } from './mailer.js'; import { FakeMailer } from './fake_mailer.js'; import type { BaseMail } from './base_mail.js'; import type { MailEvents, MailerConfig, MailerMessenger, MailTransportContract, MessageComposeCallback, MailManagerTransportFactory } from './types.js'; /** * Mail manager exposes the API to configure multiple mailers, manage * their lifecycle and switch between them. */ export declare class MailManager<KnownMailers extends Record<string, MailManagerTransportFactory>> { #private; config: MailerConfig & { default?: keyof KnownMailers; mailers: KnownMailers; }; constructor(emitter: EmitterLike<MailEvents>, config: MailerConfig & { default?: keyof KnownMailers; mailers: KnownMailers; }); /** * Configure the messenger for all the mailers managed * by the mail manager class. */ setMessenger(messenger: (mailer: Mailer<MailTransportContract>) => MailerMessenger): this; /** * Send email using the default mailer */ send(callbackOrMail: MessageComposeCallback | BaseMail, config?: unknown): Promise<Awaited<ReturnType<ReturnType<KnownMailers[keyof KnownMailers]>["send"]>>>; /** * Queue email using the default mailer */ sendLater(callbackOrMail: MessageComposeCallback | BaseMail, config?: unknown): Promise<void>; /** * Create/use an instance of a known mailer. The mailer * instances are cached for the lifecycle of the process */ use<K extends keyof KnownMailers>(mailerName?: K): Mailer<ReturnType<KnownMailers[K]>>; /** * Turn on fake mode. After this all calls to "mail.use" will * return an instance of the fake mailer */ fake(): FakeMailer; /** * Turn off fake mode and restore normal behavior */ restore(): void; /** * Clear mailer from cache and close its transport */ close<K extends keyof KnownMailers>(mailerName: K): Promise<void>; /** * Clear all mailers from cache and close their transports */ closeAll(): Promise<void>; }