import nodemailer from 'nodemailer'; import { EmailSender } from './EmailSender'; export interface SMTPConfig { host: string; port: number; secure: boolean; user: string; pass: string; from: string; } export class SMTPEmailSender implements EmailSender { private transporter: nodemailer.Transporter; private from: string; constructor( config: SMTPConfig ) { this.from = config.from; this.transporter = nodemailer.createTransport( { host: config.host, port: config.port, secure: config.secure, auth: { user: config.user, pass: config.pass } } ); } async sendEmail( to: string, subject: string, body: string ): Promise { await this.transporter.sendMail( { from: this.from, to, subject, text: body } ); } }