import nodemailer from 'nodemailer' export async function sendPasswordResetEmail(email: string, code: string) { const config = useRuntimeConfig() const transporter = nodemailer.createTransport({ host: config.emailHost, port: parseInt(config.emailPort), secure: parseInt(config.emailPort) === 465, auth: { user: config.emailUser, pass: config.emailPassword, }, }) const mailOptions = { from: config.emailFrom, to: email, subject: 'Password Reset Code - New Life Christian Church', text: `Please enter this 6 digit code to reset your password for the New Life Christian Church sermon page: ${code}`, html: `

Password Reset Request

Please enter this 6 digit code to reset your password for the New Life Christian Church sermon page:

${code}

This code will expire in 15 minutes.

If you did not request a password reset, please ignore this email.

`, } await transporter.sendMail(mailOptions) } export function generateResetCode(): string { return Math.floor(100000 + Math.random() * 900000).toString() } export async function sendSermonNotesEmail( email: string, firstName: string, sermonTitle: string, sermonDate: string, bibleReferences: string, personalAppliance: string, pastorsChallenge: string, userNotes: string ) { const config = useRuntimeConfig() const transporter = nodemailer.createTransport({ host: config.emailHost, port: parseInt(config.emailPort), secure: parseInt(config.emailPort) === 465, auth: { user: config.emailUser, pass: config.emailPassword, }, }) const mailOptions = { from: config.emailFrom, to: email, subject: `Sermon Notes: ${sermonTitle}`, text: ` Sermon Notes for ${firstName} Title: ${sermonTitle} Date: ${sermonDate} Bible References: ${bibleReferences} Personal Appliance: ${personalAppliance} Pastor's Challenge: ${pastorsChallenge} My Notes: ${userNotes || 'No notes taken'} `, html: `

Sermon Notes

${sermonTitle}

${sermonDate}

Bible References

${bibleReferences}

Personal Appliance

${personalAppliance}

Pastor's Challenge

${pastorsChallenge}

My Notes

${userNotes || 'No notes taken'}

This email was sent from New Life Christian Church.

`, } await transporter.sendMail(mailOptions) }