Add email notification system for contact form submissions
Implement a new mailer module to send email notifications upon contact form submission, integrating with SMTP settings and formatting the email content. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 3a6f3b4b-2588-4a9e-9f58-fbe9c763e594 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/koutl3W Replit-Helium-Checkpoint-Created: true
This commit is contained in:
+7
-3
@@ -8,6 +8,7 @@ import { analyzeAllArticleImages, getCachedFocalPoints } from "./focal-point";
|
||||
import { optimizeImage } from "./image-optimizer";
|
||||
import { getAuthUrl, exchangeCodeForTokens, isConnected, fetchGalleryFromDropbox, getValidAccessToken, migrateGalleryToCloudinary } from "./dropbox";
|
||||
import { listCloudinaryGalleryDetailed, deleteFromCloudinary } from "./cloudinary";
|
||||
import { sendContactEmail } from "./mailer";
|
||||
import multer from "multer";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
@@ -473,7 +474,7 @@ export async function registerRoutes(
|
||||
if (fs.existsSync(contactPath)) {
|
||||
messages = JSON.parse(fs.readFileSync(contactPath, "utf-8"));
|
||||
}
|
||||
messages.push({
|
||||
const entry = {
|
||||
id: Date.now(),
|
||||
name,
|
||||
email,
|
||||
@@ -481,9 +482,12 @@ export async function registerRoutes(
|
||||
message,
|
||||
createdAt: new Date().toISOString(),
|
||||
read: false,
|
||||
});
|
||||
};
|
||||
messages.push(entry);
|
||||
fs.writeFileSync(contactPath, JSON.stringify(messages, null, 2));
|
||||
console.log(`[contact] New message from ${name} <${email}>: ${subject || "No subject"}`);
|
||||
|
||||
const emailSent = await sendContactEmail({ name, email, subject: subject || "", message });
|
||||
console.log(`[contact] New message from ${name} <${email}>: ${subject || "No subject"} (email ${emailSent ? "sent" : "failed"})`);
|
||||
res.json({ ok: true });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ message: err.message });
|
||||
|
||||
Reference in New Issue
Block a user