feat: Containerize services with Docker Compose (PostgreSQL, Strapi CMS, Express Backend, Nginx Frontend) on custom ports >9000
This commit is contained in:
+53
-12
@@ -13,7 +13,7 @@ export default async function handler(req, res) {
|
||||
return res.status(405).json({ error: 'Method Not Allowed' });
|
||||
}
|
||||
|
||||
const { type, name, email, phone, mobile, subject, message, interests, turnstileToken } = req.body;
|
||||
const { type, name, email, phone, mobile, subject, message, interests, designation, dateTime, resumeName, turnstileToken } = req.body;
|
||||
|
||||
const contactName = name?.trim();
|
||||
const contactEmail = email?.trim();
|
||||
@@ -45,6 +45,22 @@ export default async function handler(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
// Determine per-form subject prefix and body label
|
||||
let mailSubject, formLabel, accentColor;
|
||||
if (type === 'careers') {
|
||||
mailSubject = `[Careers Application] New Application from ${contactName}`;
|
||||
formLabel = 'Careers / Job Application';
|
||||
accentColor = '#38bdf8';
|
||||
} else if (type === 'strategy') {
|
||||
mailSubject = `[Strategy Call Booking] New Session Request from ${contactName}`;
|
||||
formLabel = 'Strategy Call Session Request';
|
||||
accentColor = '#38bdf8';
|
||||
} else {
|
||||
mailSubject = `[Contact Inquiry] ${contactSubject ? contactSubject : `New Inquiry from ${contactName}`}`;
|
||||
formLabel = 'Contact Us Inquiry';
|
||||
accentColor = '#ffaa00';
|
||||
}
|
||||
|
||||
// 1. Try sending via SMTP (nodemailer)
|
||||
const smtpHost = process.env.SMTP_HOST;
|
||||
const smtpUser = process.env.SMTP_USER;
|
||||
@@ -64,23 +80,48 @@ export default async function handler(req, res) {
|
||||
});
|
||||
|
||||
const toEmail = process.env.SMTP_TO || smtpUser;
|
||||
const fromEmail = process.env.SMTP_FROM || `"Cavin Infotech Contact" <${smtpUser}>`;
|
||||
const fromEmail = process.env.SMTP_FROM || `"Cavin Infotech" <${smtpUser}>`;
|
||||
|
||||
let bodyRows = `
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};width:140px;">Name:</td><td style="padding:10px 0;color:#fff;">${contactName}</td></tr>
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Email:</td><td style="padding:10px 0;"><a href="mailto:${contactEmail}" style="color:#38bdf8;text-decoration:none;">${contactEmail}</a></td></tr>
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Phone:</td><td style="padding:10px 0;color:#fff;">${contactPhone || 'Not provided'}</td></tr>
|
||||
`;
|
||||
|
||||
if (type === 'strategy') {
|
||||
bodyRows += `
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Designation:</td><td style="padding:10px 0;color:#fff;">${designation || 'N/A'}</td></tr>
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Preferred Slot:</td><td style="padding:10px 0;color:#ffaa00;font-weight:600;">${dateTime || 'Flexible'}</td></tr>
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Interests:</td><td style="padding:10px 0;color:#fff;">${interests || 'General Consultation'}</td></tr>
|
||||
`;
|
||||
} else if (type === 'careers') {
|
||||
bodyRows += `
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Resume:</td><td style="padding:10px 0;color:#ffaa00;font-weight:600;">${resumeName || 'Attached'}</td></tr>
|
||||
`;
|
||||
} else {
|
||||
bodyRows += `
|
||||
<tr><td style="padding:10px 0;font-weight:600;color:${accentColor};">Subject:</td><td style="padding:10px 0;color:#fff;">${contactSubject}</td></tr>
|
||||
`;
|
||||
}
|
||||
|
||||
const info = await transporter.sendMail({
|
||||
from: fromEmail,
|
||||
to: toEmail,
|
||||
replyTo: `"${contactName}" <${contactEmail}>`,
|
||||
subject: `[Contact Form] ${contactSubject}`,
|
||||
text: `Name: ${contactName}\nEmail: ${contactEmail}\nPhone: ${contactPhone}\nSubject: ${contactSubject}\n\nMessage:\n${contactMessage}`,
|
||||
subject: mailSubject,
|
||||
text: `${formLabel}\n\nName: ${contactName}\nEmail: ${contactEmail}\nPhone: ${contactPhone}\nSubject/Type: ${contactSubject}\n\nMessage:\n${contactMessage}`,
|
||||
html: `
|
||||
<div style="font-family: Arial, sans-serif; background: #020710; color: #fff; padding: 30px; border-radius: 12px;">
|
||||
<h2 style="color: #ffaa00; margin-top: 0;">Cavin Infotech - Contact Inquiry</h2>
|
||||
<p><strong>Name:</strong> ${contactName}</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:${contactEmail}" style="color: #38bdf8;">${contactEmail}</a></p>
|
||||
<p><strong>Phone:</strong> ${contactPhone || 'Not provided'}</p>
|
||||
<p><strong>Subject:</strong> ${contactSubject}</p>
|
||||
<div style="margin-top: 20px; padding: 15px; background: #0b1528; border-left: 4px solid #ffaa00; border-radius: 6px;">
|
||||
<p style="margin: 0; white-space: pre-line;">${contactMessage}</p>
|
||||
<div style="font-family:'Segoe UI',Helvetica,Arial,sans-serif;background-color:#020710;color:#f8fafc;padding:40px 20px;max-width:650px;margin:0 auto;border-radius:16px;border:1px solid #1e293b;">
|
||||
<div style="text-align:center;padding-bottom:24px;border-bottom:1px solid #334155;">
|
||||
<h2 style="color:${accentColor};font-size:24px;margin:0;font-weight:700;">Cavin Infotech</h2>
|
||||
<p style="color:#94a3b8;font-size:14px;margin-top:6px;">${formLabel}</p>
|
||||
</div>
|
||||
<div style="padding:24px 0;">
|
||||
<table style="width:100%;border-collapse:collapse;font-size:15px;">${bodyRows}</table>
|
||||
${contactMessage ? `<div style="margin-top:24px;padding:20px;background:#0b1528;border-left:4px solid ${accentColor};border-radius:8px;"><p style="margin:0;color:#f1f5f9;font-size:15px;line-height:1.6;white-space:pre-line;">${contactMessage}</p></div>` : ''}
|
||||
</div>
|
||||
<div style="text-align:center;padding-top:20px;border-top:1px solid #334155;color:#64748b;font-size:12px;">
|
||||
Submitted on ${new Date().toLocaleString()} from Cavin Infotech Website
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user