/*Canopy - The next generation of stoner streaming software Copyright (C) 2024-2025 Rainbownapkin and the TTN Community This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see .*/ //Config const config = require('../../config.json'); //NPM imports const nodeMailer = require("nodemailer"); //Setup mail transport const transporter = nodeMailer.createTransport({ host: config.mail.host, port: config.mail.port, secure: config.mail.secure, auth: { user: config.mail.address, pass: config.mail.pass } }); module.exports.mailem = async function(to, subject, body, htmlBody = false){ //Create mail object const mailObj = { from: `"Tokebot🤖💨"<${config.mail.address}>`, to, subject }; //If we're sending HTML if(htmlBody){ //set body as html mailObj.html = body; //If we're sending plaintext }else{ //Set body as plaintext mailObj.text = body } //Send mail based on mail object const sentMail = await transporter.sendMail(mailObj); //return the mail info return sentMail; } module.exports.sendAddressVerification = async function(requestDB, userDB, newEmail){ //Send the reset url via email await module.exports.mailem( newEmail, `Email Change Request - ${userDB.user}`, `

Email Change Request

A request to change the email associated with the ${config.instanceName} account '${userDB.user}' to this address has been requested.
Click here to confirm this change.

If you received this email without request, feel free to ignore and delete it! -Tokebot`, true ); //If the user has a pre-existing email address if(userDB.email != null && userDB.email != ""){ await module.exports.mailem( userDB.email, `Email Change Request - ${userDB.user}`, `

Email Change Request Notification

A request to change the email associated with the ${config.instanceName} account '${userDB.user}' to another address has been requested.
If you received this email without request, you should immediately change your password and contact the server adminsitrator! -Tokebot`, true ); } }