UNPKG

2.01 kBTypeScriptView Raw
1/*!
2 * @package @coolgk/utils
3 * @version 2.1.5
4 * @link https://github.com/coolgk/node-utils
5 * @license MIT
6 * @author Daniel Gong <daniel.k.gong@gmail.com>
7 *
8 * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved.
9 * Licensed under the MIT License.
10 */
11
12/*!
13 * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved.
14 * Licensed under the MIT License.
15 */
16import { lookup } from 'mime-types';
17import { stripTags } from '@coolgk/string';
18export 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}
30export interface IEmailClient {
31 send: (param1: any, param2: any) => any;
32}
33export interface IEmailConfigWithClient {
34 readonly emailClient: IEmailClient;
35 readonly stripTags?: typeof stripTags;
36 readonly getMimeType?: typeof lookup;
37}
38export interface IEmailAddress {
39 name?: string;
40 readonly email: string;
41}
42export 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}
51export 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}
61export 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}
69export default Email;