/** * MailDev - mailserver */ import type { Attachment, Envelope, Mail } from "./type"; import type { OutgoingOptions } from "./outgoing"; import type { ReadStream } from "fs"; import { MailBuffer } from "./mailbuffer"; import { Outgoing } from "./outgoing"; import { SMTPServer } from "smtp-server"; export interface MailServerOptions { port?: number; host?: string; mailDir?: string; hideExtensions?: string[]; isSecure?: boolean; auth?: { user: string; pass: string; }; ssl?: { certPath: string; keyPath: string; }; hide8BITMIME?: boolean; hidePIPELINING?: boolean; hideSMTPUTF8?: boolean; outgoing?: OutgoingOptions; } export declare class MailServer { port: number; host: string; mailDir: string; store: Envelope[]; eventEmitter: any; mailEventSubjectMapper: (Mail: any) => string | undefined; smtp: typeof SMTPServer; outgoing: Outgoing | undefined; private _reloadInProgress; /** * Extend Event Emitter methods * events: * 'new' - emitted when new email has arrived */ emit: any; on: any; off: any; once: any; prependListener: any; prependOnceListener: any; removeListener: any; removeAllListeners: any; next(subject: string): Promise; /** * Use an internal array to store received email even if not consummed * Use `.return()` to close it **/ iterator(subject: string): AsyncIterator; /** * Return a struct which store received emails. * Then allow to obtain a `Promise` dependant on a predicate `(Mail) => boolean`. * Allow to wait for `Mail` independant of their order of arrival. */ buffer(subject: string, defaultTimeout?: number): MailBuffer; constructor(options?: MailServerOptions, mailEventSubjectMapper?: (Mail: any) => string | undefined); /** * Start the mailServer */ listen(): Promise; /** * Stop the mailserver */ close(): Promise; isOutgoingEnabled(): boolean; getOutgoingHost(): string | undefined; /** * Set Auto Relay Mode, automatic send email to recipient */ setAutoRelayMode(enabled: boolean, emailAddress: string | undefined, rules: { allow?: string; deny?: string; }[] | string | undefined): void; relayMail(mail: Mail, isAutoRelay?: boolean): Promise; /** * Get an email by id */ getEmail(id: string, setRead: boolean): Promise; /** * Returns a readable stream of the raw email */ getRawEmail(id: string): Promise; /** * Returns the html of a given email */ getEmailHTML(id: string, baseUrl?: string): Promise; /** * Set all emails to read */ readAllEmail(): number; getAllEnvelope(): Envelope[]; getAllEmail(): Promise; deleteEmail(id: string): Promise; deleteAllEmail(): Promise; /** * Delete everything in the mail directory */ clearMailDir(): Promise; /** * Returns the content type and a readable stream of the file */ getEmailAttachment(id: string, filename: string): Promise; /** * Download a given email */ getEmailEml(id: any): Promise<[string, string, ReadStream]>; loadMailsFromDirectory(): Promise; private _loadMailsFromDirectory; }