@jackiemacklein/nettz-utils
Version:
Serviços de imagem, e-mail, códigos de barras, utilitários numéricos e componentes React para apps Node.js com TypeScript
62 lines (61 loc) • 2.08 kB
TypeScript
export interface EmailAttachment {
filename: string;
content: Buffer | string;
contentType?: string;
}
export interface EmailOptions {
to: string | string[];
subject: string;
text?: string;
html?: string;
attachments?: EmailAttachment[];
cc?: string | string[];
bcc?: string | string[];
}
export interface EmailParameters {
SMTP_FROM_EMAIL: string;
SMTP_FROM_NAME: string;
SMTP_PROVIDER: "Gmail" | "Outlook" | "Brevo" | "SMTP";
SMTP_HOST: string;
SMTP_PORT: string;
SMTP_SECURITY: "SSL" | "STARTTLS" | "TLS";
SMTP_USERNAME: string;
SMTP_PASSWORD: string;
}
declare class EmailService {
private static instance;
private parameters;
private constructor();
static getInstance(): EmailService;
/**
* @param params - Parâmetros de configuração do email
*/
setParameters(params: EmailParameters): void;
private getParameter;
private getSmtpProvider;
private sendViaNodemailer;
/**
* @param options - Opções de envio do email
* @param log - Se deve mostrar o log das informações do email
* @returns - Promise que resolve com true se o email foi enviado com sucesso, false caso contrário
*/
sendEmail(options: EmailOptions, log?: boolean): Promise<boolean>;
/**
* @param to - Email do destinatário
* @param subject - Assunto do email
* @param message - Mensagem do email
* @param isHtml - Se a mensagem é HTML
* @param log - Se deve mostrar o log das informações do email
* @returns - Promise que resolve com true se o email foi enviado com sucesso, false caso contrário
*/
sendSimpleEmail(to: string | string[], subject: string, message: string, isHtml?: boolean, log?: boolean): Promise<boolean>;
/**
* @returns - Promise que resolve com true se a conexão SMTP foi estabelecida com sucesso, false caso contrário
*/
testConnection(): Promise<{
success: boolean;
message: string;
}>;
}
declare const _default: EmailService;
export default _default;