UNPKG

@adonisjs/mail

Version:

Mail provider for adonis framework and has support for all common mailing services to send emails

56 lines (55 loc) 2.15 kB
import type { EmitterLike } from '@adonisjs/core/types/events'; 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>; }