import nodemailer, { Transporter } from "nodemailer"; interface IMailOptions { email: string; subject: string; data: { [key: string]: any }; } const sendMail = async (options: IMailOptions): Promise => { const transporter: Transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: parseInt(process.env.SMTP_PORT || "587"), // service: process.env.SMTP_SERVICE, auth: { user: process.env.SMTP_MAIL, pass: process.env.SMTP_PASSWORD, }, }); const { email, subject, data } = options; const mailOptions = { from: process.env.SMTP_MAIL, to: email, subject: subject, html: emailTemplate(data.email, data.code), }; await transporter.sendMail(mailOptions); }; const emailTemplate = (email: string, code: string) => { return ` Storm registration `; }; export default sendMail;