UNPKG

3.24 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import JSONTransport = require("./lib/json-transport");
4import Mail = require("./lib/mailer");
5import MailMessage = require("./lib/mailer/mail-message");
6import SendmailTransport = require("./lib/sendmail-transport");
7import SESTransport = require("./lib/ses-transport");
8import SMTPPool = require("./lib/smtp-pool");
9import SMTPTransport = require("./lib/smtp-transport");
10import StreamTransport = require("./lib/stream-transport");
11
12export type SendMailOptions = Mail.Options;
13
14export type Transporter<T = any, D extends TransportOptions = TransportOptions> = Mail<T, D>;
15
16export type SentMessageInfo = any;
17
18export interface Transport<T = any, D extends TransportOptions = TransportOptions> {
19 mailer?: Transporter<T, D> | undefined;
20
21 name: string;
22 version: string;
23
24 send(mail: MailMessage<T>, callback: (err: Error | null, info: T) => void): void;
25
26 verify?(callback: (err: Error | null, success: true) => void): void;
27 verify?(): Promise<true>;
28
29 close?(): void;
30}
31
32export interface TransportOptions {
33 component?: string | undefined;
34}
35
36export interface TestAccount {
37 user: string;
38 pass: string;
39 smtp: { host: string; port: number; secure: boolean };
40 imap: { host: string; port: number; secure: boolean };
41 pop3: { host: string; port: number; secure: boolean };
42 web: string;
43}
44
45export function createTransport(
46 transport: SMTPPool | SMTPPool.Options,
47 defaults?: SMTPPool.Options,
48): Transporter<SMTPPool.SentMessageInfo, SMTPPool.Options>;
49export function createTransport(
50 transport: SendmailTransport | SendmailTransport.Options,
51 defaults?: SendmailTransport.Options,
52): Transporter<SendmailTransport.SentMessageInfo, SendmailTransport.Options>;
53export function createTransport(
54 transport: StreamTransport | StreamTransport.Options,
55 defaults?: StreamTransport.Options,
56): Transporter<StreamTransport.SentMessageInfo, StreamTransport.Options>;
57export function createTransport(
58 transport: JSONTransport | JSONTransport.Options,
59 defaults?: JSONTransport.Options,
60): Transporter<JSONTransport.SentMessageInfo, JSONTransport.Options>;
61export function createTransport(
62 transport: SESTransport | SESTransport.Options,
63 defaults?: SESTransport.Options,
64): Transporter<SESTransport.SentMessageInfo, SESTransport.Options>;
65export function createTransport(
66 transport?: SMTPTransport | SMTPTransport.Options | string,
67 defaults?: SMTPTransport.Options,
68): Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
69// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
70export function createTransport<T>(
71 transport: Transport<T> | TransportOptions,
72 defaults?: TransportOptions,
73): Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
74
75export function createTestAccount(
76 apiUrl: string,
77 callback: (err: Error | null, testAccount: TestAccount) => void,
78): void;
79export function createTestAccount(callback: (err: Error | null, testAccount: TestAccount) => void): void;
80export function createTestAccount(apiUrl?: string): Promise<TestAccount>;
81
82export function getTestMessageUrl(info: SESTransport.SentMessageInfo | SMTPTransport.SentMessageInfo): string | false;
83
\No newline at end of file