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