Monorepo for Aesthetic.Computer aesthetic.computer
at main 31 lines 715 B view raw
1import nodemailer from "nodemailer"; 2 3export async function email(options) { 4 const config = { 5 host: process.env.SMTP_SERVER, 6 port: 587, 7 secure: false, 8 auth: { 9 user: process.env.SMTP_USER, 10 pass: process.env.SMTP_PASS, 11 }, 12 }; 13 14 if (options.auth) { 15 config.auth = options.auth; 16 delete options.auth; 17 } 18 19 if (!options.from) 20 options.from = 21 config.auth.user?.split("@")[1] + " <" + config.auth.user + ">"; 22 23 try { 24 const transporter = nodemailer.createTransport(config); 25 await transporter.sendMail(options); 26 return true; 27 } catch (error) { 28 console.error("❌📧 Error sending email:", error); 29 return false; 30 } 31}