From 848387d69c08c3cbccefd6c8a7b1cb0ded4644b4 Mon Sep 17 00:00:00 2001 From: kayjaydee Date: Fri, 17 Apr 2026 09:28:54 +0200 Subject: [PATCH] feat(contact): nouvelle template email terminal-style --- server/api/contact.post.ts | 79 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/server/api/contact.post.ts b/server/api/contact.post.ts index 1eec936..bc1e899 100644 --- a/server/api/contact.post.ts +++ b/server/api/contact.post.ts @@ -36,12 +36,85 @@ export default defineEventHandler(async (event) => { return map[c] ?? c }) + const escapedEmail = email.replace(/[&<>"']/g, (c: string) => { + const map: Record = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' } + return map[c] ?? c + }) + + const dateStr = new Date().toLocaleString('fr-FR', { + day: 'numeric', month: 'long', year: 'numeric', hour: '2-digit', minute: '2-digit', + timeZone: 'Europe/Paris', + }) + + const html = ` + + + + + +
+ + + + +
+ + + + + +
Killian' DAL-CIN + + New Message +
+
+ + +
+ + + +
+ + + + contact@portfolio +
+
+ $ from: ${escapedName}
+ $ email: ${escapedEmail}
+ $ date: ${dateStr} +
+
+
+ + +
+ + +
+

Message

+
${escapedMessage.replace(/\n/g, '
')}
+
+
+ + + + + +
killiandalcin.frBuilt with Nuxt
+
+
+ +` + await transporter.sendMail({ - from: `"Portfolio" <${config.smtpUser}>`, + from: `"Portfolio Killian'" <${config.smtpUser}>`, to: config.smtpTo, - subject: `Contact portfolio - ${name}`, + replyTo: email, + subject: `Nouveau message — ${name}`, text: `De: ${name} <${email}>\n\n${message}`, - html: `

De: ${escapedName} <${email}>

${escapedMessage.replace(/\n/g, '
')}

`, + html, }) return { success: true }