@adaptivestone/framework-module-email
Version:
Adaptive stone node js framework module email
71 lines (70 loc) • 2.72 kB
TypeScript
import defaultMailConfig from './config/mail.ts';
import type { TMinimalI18n, TMinimalApp } from './types.d.ts';
declare class Mail {
#private;
/**
* Adaptive stone framework application
*/
app: TMinimalApp;
/**
* Template full path
*/
template: string;
/**
* Data to render in template. Object with value that available inside template
* @type {object}
*/
templateData: {};
/**
* Locale to render template
* @type {string}
*/
locale: string;
/**
* i18n object. Fallback if you have no real i18n object
*/
i18n: TMinimalI18n;
/**
* Construct mail class
* @param {TMinimalI18n} app
* @param {string} template template name
* @param {object} [templateData={}] data to render in template. Object with value that available inside template
* @param {object} [i18n] data to render in template
*/
constructor(app: TMinimalApp, template: string, templateData?: {}, i18n?: TMinimalI18n | null);
/**
* Render template
* @return {Promise}
*/
renderTemplate(): Promise<{
htmlRaw: string;
subject: string;
text: string;
inlinedHTML: string;
}>;
/**
* Send email
* @param {string | Array<string>} to email send to
* @param {string} [from = mailConfig.from]
* @param {object} [aditionalNodemailerOptions = {}] additional option to nodemailer
* @return {Promise}
*/
send(to: string | Array<string>, from?: string, aditionalNodemailerOptions?: {}): Promise<import("nodemailer/lib/smtp-transport/index.d.ts").SentMessageInfo>;
/**
* Send provided text (html) to email. Low level function. All data should be prepared before sending (like inline styles)
* @param {TMinimalI18n} app application
* @param {string | Array<string>} to send to
* @param {string} subject email topic
* @param {string} html hmlt body of emain
* @param {string} [text] if not provided will be generated from html string
* @param {string} [from = mailConfig.from] from. If not provided will be grabbed from config
* @param {object} [additionalNodeMailerOption = {}] any otipns to pass to nodemailer https://nodemailer.com/message/
*/
static sendRaw(app: TMinimalApp, to: string | Array<string>, subject: string, html: string, text?: string, from?: string, additionalNodeMailerOption?: {}): Promise<import("nodemailer/lib/smtp-transport/index.d.ts").SentMessageInfo>;
/**
* Get final config. Method to get final config.
* @param {TMinimalI18n} app application
*/
static getConfig(app: TMinimalApp): typeof defaultMailConfig;
}
export default Mail;