UNPKG

lynx-framework

Version:

lynx is a NodeJS framework for Web Development, based on decorators and the async/await support.

37 lines (36 loc) 2.1 kB
import * as express from 'express'; export interface MailClient { init(): Promise<void>; /** * Utility method to send emails from a controller. * This method is similar to the `sendMail` method, but define a lower level API. * Indeed, it directly accepts the text and the html of the email, and not the templates urls. * @param dest the email destination (can also be an array of addresses) * @param subject the subject of the email * @param text the text version of the email * @param html the html version of the email */ sendRawMail(dest: string | string[], subject: string, text: string, html: string): Promise<boolean>; /** * Utility method to send an email from a controller. This method is async, * so use the await keyword (or eventually a promise) to correctly read the * return value. * This method uses the template engine to compile the email. * NOTE: internally, this method uses the `sendRawMail` method. * @param req the current request * @param dest the email destination (can also be an array of addresses) * @param subjectTemplateString the subject of the email, that can also be a string template * @param textTemplate the text version of the email, referencing a path in the view folders * @param htmlTemplate the html version of the email, referencing a path in the view folders * @param context a plain object containing any necessary data needed by the view */ sendMail(req: express.Request, dest: string | string[], subjectTemplateString: string, textTemplate: string, htmlTemplate: string, context: any): Promise<boolean>; } export declare class NodemailerClient implements MailClient { constructor(); private guard; private mailClient; init(): Promise<void>; sendRawMail(dest: string | string[], subject: string, text: string, html: string): Promise<boolean>; sendMail(req: express.Request, dest: string | string[], subjectTemplateString: string, textTemplate: string, htmlTemplate: string, context: any): Promise<boolean>; }