diff --git a/.gitignore b/.gitignore index 499540b..e5024fd 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,8 @@ run* install* public static/css -tailwindcss \ No newline at end of file +tailwindcss + +# .gitignore +node_modules/ +.env diff --git a/server.js b/server.js new file mode 100644 index 0000000..5ac60fe --- /dev/null +++ b/server.js @@ -0,0 +1,59 @@ +// server.js + +// Load environment variables from .env file +require('dotenv').config(); + +const express = require('express'); +const nodemailer = require('nodemailer'); +const bodyParser = require('body-parser'); + +const app = express(); +const PORT = process.env.PORT || 3000; + +// Middleware to parse JSON and urlencoded form data +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: true })); + +// POST endpoint to handle form submissions +app.post('/api/contact', async (req, res) => { + try { + // Get form data from request body + const { firstName, lastName, email, phoneNumber, message } = req.body; + + // Create transporter for sending emails (replace with your email service details) + const transporter = nodemailer.createTransport({ + service: 'Gmail', + auth: { + user: process.env.EMAIL_USER, // Using environment variable for email user + pass: process.env.EMAIL_PASS // Using environment variable for email password + } + }); + + // Email content + const mailOptions = { + from: process.env.EMAIL_USER, // Replace with your email address + to: 'recipient@example.com', // Replace with recipient email address + subject: 'New Message from Contact Form', + html: ` +
Name: ${firstName} ${lastName}
+Email: ${email}
+Phone Number: ${phoneNumber}
+Message:
${message}
Proin volutpat consequat porttitor cras nullam gravida at. Orci molestie a eu arcu. Sed ut tincidunt integer elementum id sem. Arcu sed malesuada et magna.
+At OurWorld, we value your feedback and inquiries. Whether you're interested in our ventures, have questions about our technologies, or want to collaborate, we're here to connect. Reach out to us today and let's build a better digital future together.