Files
photography_form_worker/sendEmail.ts
2025-05-15 13:32:55 +10:00

42 lines
1.0 KiB
TypeScript

import nodemailer from 'nodemailer'; // if using ESModules
// const nodemailer = require('nodemailer'); // if using CommonJS
export async function sendEmail(formData: {
name: string;
email: string;
phone?: string;
location?: string;
info?: string;
}) {
const transporter = nodemailer.createTransport({
host: 'smtp.titan.email',
port: 465,
secure: true,
auth: {
user: 'contact@jackbeeby.au',
pass: 'Charlie2017$',
},
});
const mailOptions = {
from: '"Jack Beeby" <contact@jackbeeby.au>',
to: 'beebyjack1@gmail.com',
subject: 'Photography Client Notification',
text: `
New photography enquiry received:
Name: ${formData.name}
Email: ${formData.email}
Phone: ${formData.phone || 'N/A'}
Location: ${formData.location || 'N/A'}
Info: ${formData.info || 'N/A'}
`,
};
try {
const info = await transporter.sendMail(mailOptions);
console.log('Message sent:', info.messageId);
} catch (error) {
console.error('Error sending mail:', error);
}
}