'use strict'; const logs = require('../common/logs'); const nodemailer = require('nodemailer'); const log = new logs('NodeMailer'); const SERVER_URL = process.env.SERVER_URL; const EMAIL_HOST = process.env.EMAIL_HOST; const EMAIL_PORT = process.env.EMAIL_PORT; const EMAIL_USERNAME = process.env.EMAIL_USERNAME; const EMAIL_PASSWORD = process.env.EMAIL_PASSWORD; const EMAIL_VERIFICATION = process.env.EMAIL_VERIFICATION === 'true' || false; const SUPPORT = 'https://codecanyon.net/item/mirotalk-webrtc-ultimate-bundle-for-seamless-live-smart-communication/47976343'; // Thank you! log.info('Email', { verification: EMAIL_VERIFICATION, host: EMAIL_HOST, port: EMAIL_PORT, username: EMAIL_USERNAME, password: EMAIL_PASSWORD, }); const transport = nodemailer.createTransport({ host: EMAIL_HOST, port: EMAIL_PORT, auth: { user: EMAIL_USERNAME, pass: EMAIL_PASSWORD, }, }); function sendConfirmationEmail(name, email, confirmationCode) { transport .sendMail({ from: EMAIL_USERNAME, to: email, subject: 'MiroTalk WEB - Please confirm your email', html: `

Email Confirmation

Hello ${name}

Thank you for subscribing. Please confirm your email by clicking on the following link

Click here to confirm

If it wasn't you, please ignore this email.

`, }) .catch((err) => log.error(err)); } function sendConfirmationOkEmail(name, toEmail, credential) { const credentialObj = JSON.parse(credential); const { role, email, username, password, active, allow, allowedRooms, createdAt, updatedAt } = credentialObj; log.debug('sendConfirmationOkEmail', credentialObj); transport .sendMail({ from: EMAIL_USERNAME, to: toEmail, subject: 'MiroTalk WEB - Email confirmed', html: `

Email Confirmed

Hello ${name}

Thank you for confirmation. Here your account info

Role ${role}
Email ${email}
Username ${username}
Password ${password}
Active ${active}
Allowed services ${allow}
Allowed rooms ${allowedRooms}
Created at ${createdAt}
Updated at ${updatedAt}

Home page

${SERVER_URL}

Enjoying our app? Unlock its full potential with a MiroTalk purchase on CodeCanyon.

Get License, Full Source Code, and Priority Support, plus access to all updates. Your purchase fuels future improvements!

Ready to upgrade? Click below to choose your MiroTalk package.

Purchase from CodeCanyon

Thank you for your support!

MiroTalk Team

`, }) .catch((err) => log.error(err)); } module.exports = { sendConfirmationEmail, sendConfirmationOkEmail, EMAIL_VERIFICATION, SUPPORT, };