// src/email.js // Email service using Nodemailer for subscription linking notifications const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: 587, secure: false, // Use STARTTLS auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS } }); /** * Send Discord linking email to subscriber * @param {string} name - Customer name * @param {string} email - Customer email address * @param {string} token - Secure linking token * @returns {Promise} - Nodemailer send result */ async function sendLinkingEmail(name, email, token) { const link = `${process.env.APP_URL}/link?token=${token}`; const textBody = `Hi ${name}, Thanks for subscribing to Firefrost Gaming! To access your game servers, please connect your Discord account: ${link} This link expires in 24 hours. Once connected, you'll see your server channels in Discord with IPs pinned at the top. Questions? Join us in Discord: https://firefrostgaming.com/discord - The Firefrost Team 🔥❄️`; return transporter.sendMail({ from: `"Firefrost Gaming" <${process.env.SMTP_USER}>`, to: email, subject: 'Welcome to Firefrost Gaming! 🔥❄️ One More Step...', text: textBody }); } module.exports = { sendLinkingEmail };