UNPKG

1.75 kBTypeScriptView Raw
1/*!
2 * @package @coolgk/utils
3 * @version 1.1.3
4 * @link https://www.npmjs.com/package/@coolgk/utils
5 * @license MIT
6 */
7
8import mimeTypes = require('mime-types');
9import { stripTags } from '@coolgk/string';
10export 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}
22export interface IEmailClient {
23 send: (param1: any, param2: any) => any;
24}
25export interface IEmailConfigWithClient {
26 readonly emailClient: IEmailClient;
27 readonly stripTags?: typeof stripTags;
28 readonly getMimeType?: typeof mimeTypes.lookup;
29}
30export interface IEmailAddress {
31 name?: string;
32 readonly email: string;
33}
34export 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}
43export 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}
53export 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}
61export default Email;