initial update
This commit is contained in:
42
sendEmail.ts
Normal file
42
sendEmail.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user