UNPKG

2.88 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> = Mail<T>;
15
16export type SentMessageInfo = any;
17
18export interface Transport<T = any> {
19 mailer?: Transporter<T> | 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?: SMTPTransport | SMTPTransport.Options | string,
47 defaults?: SMTPTransport.Options,
48): Transporter<SMTPTransport.SentMessageInfo>;
49export function createTransport(
50 transport: SMTPPool | SMTPPool.Options,
51 defaults?: SMTPPool.Options,
52): Transporter<SMTPPool.SentMessageInfo>;
53export function createTransport(
54 transport: SendmailTransport | SendmailTransport.Options,
55 defaults?: SendmailTransport.Options,
56): Transporter<SendmailTransport.SentMessageInfo>;
57export function createTransport(
58 transport: StreamTransport | StreamTransport.Options,
59 defaults?: StreamTransport.Options,
60): Transporter<StreamTransport.SentMessageInfo>;
61export function createTransport(
62 transport: JSONTransport | JSONTransport.Options,
63 defaults?: JSONTransport.Options,
64): Transporter<JSONTransport.SentMessageInfo>;
65export function createTransport(
66 transport: SESTransport | SESTransport.Options,
67 defaults?: SESTransport.Options,
68): Transporter<SESTransport.SentMessageInfo>;
69export function createTransport<T>(
70 transport: Transport<T> | TransportOptions,
71 defaults?: TransportOptions,
72): Transporter<T>;
73
74export function createTestAccount(
75 apiUrl: string,
76 callback: (err: Error | null, testAccount: TestAccount) => void,
77): void;
78export function createTestAccount(callback: (err: Error | null, testAccount: TestAccount) => void): void;
79export function createTestAccount(apiUrl?: string): Promise<TestAccount>;
80
81export function getTestMessageUrl(info: SESTransport.SentMessageInfo | SMTPTransport.SentMessageInfo): string | false;
82
\No newline at end of file