1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { lookup } from 'mime-types';
|
17 | import { stripTags } from '@coolgk/string';
|
18 | export interface IEmailConfig {
|
19 | readonly host: string;
|
20 | readonly stripTags?: typeof stripTags;
|
21 | readonly getMimeType?: typeof lookup;
|
22 | readonly user?: string;
|
23 | readonly password?: string;
|
24 | readonly port?: number;
|
25 | readonly ssl?: boolean;
|
26 | readonly tls?: boolean;
|
27 | readonly domain?: string;
|
28 | readonly authentication?: string[];
|
29 | }
|
30 | export interface IEmailClient {
|
31 | send: (param1: any, param2: any) => any;
|
32 | }
|
33 | export interface IEmailConfigWithClient {
|
34 | readonly emailClient: IEmailClient;
|
35 | readonly stripTags?: typeof stripTags;
|
36 | readonly getMimeType?: typeof lookup;
|
37 | }
|
38 | export interface IEmailAddress {
|
39 | name?: string;
|
40 | readonly email: string;
|
41 | }
|
42 | export interface IEmailAttachment {
|
43 | readonly path: string;
|
44 | name?: string;
|
45 | type?: string;
|
46 | readonly method?: string;
|
47 | readonly headers?: {
|
48 | [propName: string]: string;
|
49 | };
|
50 | }
|
51 | export interface ISendConfig {
|
52 | readonly subject: string;
|
53 | readonly message?: string;
|
54 | readonly from: string | IEmailAddress;
|
55 | readonly to: (string | IEmailAddress)[];
|
56 | readonly cc?: (string | IEmailAddress)[];
|
57 | readonly bcc?: (string | IEmailAddress)[];
|
58 | readonly attachments?: IEmailAttachment[];
|
59 | [key: string]: any;
|
60 | }
|
61 | export declare class Email {
|
62 | private _emailClient;
|
63 | private _stripTags;
|
64 | private _getMimeType;
|
65 | constructor(options?: (IEmailConfig | IEmailConfigWithClient));
|
66 | send(options: ISendConfig): Promise<{}>;
|
67 | private _formatEmailAddress(emails);
|
68 | }
|
69 | export default Email;
|