UNPKG

@coolgk/utils

Version:

javascript, typescript utility and wrapper functions and classes: array, string, base64, ampq, bcrypt, cache, captcha, csv, email, jwt, number, pdf, tmp, token, unit conversion, url params, session, form data, google sign in, facebook sign in

70 lines (68 loc) 1.8 kB
/*! * @package @coolgk/utils * @version 3.1.4 * @link https://github.com/coolgk/node-utils * @license MIT * @author Daniel Gong <daniel.k.gong@gmail.com> * * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved. * Licensed under the MIT License. */ /*! * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved. * Licensed under the MIT License. */ import { lookup } from 'mime-types'; import { stripTags } from '@coolgk/string'; export interface IEmailOptions { host: string; stripTags?: typeof stripTags; getMimeType?: typeof lookup; user?: string; password?: string; port?: number; ssl?: boolean; tls?: boolean; domain?: string; authentication?: string[]; } export interface IEmailClient { send: (param1: any, param2: any) => any; } export interface IEmailConfigWithClient { emailClient: IEmailClient; stripTags?: typeof stripTags; getMimeType?: typeof lookup; } export interface IEmailAddress { name?: string; email: string; } export interface IEmailAttachment { path: string; name?: string; type?: string; method?: string; headers?: { [propName: string]: string; }; } export interface ISendOptions { subject: string; message?: string; from: string | IEmailAddress; to: (string | IEmailAddress)[]; cc?: (string | IEmailAddress)[]; bcc?: (string | IEmailAddress)[]; attachments?: IEmailAttachment[]; [key: string]: any; } export declare class Email { private _emailClient; private _stripTags; private _getMimeType; constructor(options?: IEmailOptions | IEmailConfigWithClient); send(options: ISendOptions): Promise<any>; private _formatEmailAddress(emails); } export default Email;