feat: send confirmation email to contact form submitter
Schickt nach eingehender Anfrage automatisch eine Bestätigungsmail an den Anfragenden mit Betreff, Dankestext und direkter Telefonnummer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c266931822
commit
2a91084737
|
|
@ -1,5 +1,5 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { sendeKontaktEmail } from "@/lib/mailer";
|
||||
import { sendeKontaktEmail, sendeAnfrageBestaetigung } from "@/lib/mailer";
|
||||
import { createServiceClient } from "@/lib/supabase";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
|
|
@ -24,6 +24,10 @@ export async function POST(request: Request) {
|
|||
console.error("[Contact] Supabase insert error:", err);
|
||||
}
|
||||
|
||||
sendeAnfrageBestaetigung({ name, email, betreff }).catch((err) =>
|
||||
console.error("[Contact] Bestätigungsmail fehlgeschlagen:", err)
|
||||
);
|
||||
|
||||
if (!result.sent && !result.queued) {
|
||||
console.error(
|
||||
`[Contact] UNZUSTELLBAR – Anfrage konnte weder gesendet noch in Queue gespeichert werden:\n` +
|
||||
|
|
|
|||
|
|
@ -115,6 +115,52 @@ export async function sendeRegistrierungsBestaetigung(
|
|||
);
|
||||
}
|
||||
|
||||
export async function sendeAnfrageBestaetigung(data: {
|
||||
name: string;
|
||||
email: string;
|
||||
betreff: string;
|
||||
}): Promise<void> {
|
||||
const html = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head><meta charset="UTF-8"></head>
|
||||
<body style="font-family:system-ui,sans-serif;color:#e2e8f0;max-width:600px;margin:0 auto;padding:0">
|
||||
<div style="background:#18212f;padding:20px 24px;border-bottom:2px solid #f97316">
|
||||
<h1 style="color:#f97316;margin:0;font-size:20px;font-weight:700">MBO Tech IT</h1>
|
||||
<p style="color:rgba(255,255,255,0.6);margin:4px 0 0;font-size:13px">Anfrage erhalten</p>
|
||||
</div>
|
||||
<div style="padding:24px;background:#1e2a3b">
|
||||
<h2 style="margin:0 0 16px;font-size:18px;color:#f8fafc">Vielen Dank für Ihre Anfrage, ${data.name}!</h2>
|
||||
<p style="color:#94a3b8;margin:0 0 16px;line-height:1.6">
|
||||
Ihre Anfrage zum Thema <strong style="color:#f8fafc">„${data.betreff}"</strong> ist bei uns eingegangen.
|
||||
Wir melden uns schnellstmöglich bei Ihnen.
|
||||
</p>
|
||||
<p style="color:#94a3b8;margin:0 0 24px;line-height:1.6">
|
||||
Bei dringenden Anliegen erreichen Sie uns direkt unter:<br>
|
||||
<a href="tel:+4917193451093" style="color:#f97316;font-weight:600">+49 171 9345193</a>
|
||||
</p>
|
||||
<div style="padding:12px 16px;background:#111925;border-left:3px solid #f97316;border-radius:0 4px 4px 0">
|
||||
<p style="margin:0;font-size:13px;color:#64748b">Betreff: ${data.betreff}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding:12px 24px;background:#111925;border-top:1px solid rgba(255,255,255,0.1)">
|
||||
<p style="margin:0;font-size:11px;color:#64748b">MBO Tech IT · <a href="${process.env.APP_URL ?? "https://mbo-tech-it.de"}" style="color:#64748b">${process.env.APP_URL ?? "https://mbo-tech-it.de"}</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
await sendWithFallback(
|
||||
{
|
||||
from: `"MBO Tech IT" <${process.env.SMTP_FROM}>`,
|
||||
to: data.email,
|
||||
subject: `Ihre Anfrage ist eingegangen – MBO Tech IT`,
|
||||
text: `Hallo ${data.name},\n\nvielen Dank für Ihre Anfrage zum Thema „${data.betreff}". Wir melden uns schnellstmöglich bei Ihnen.\n\nBei dringenden Anliegen erreichen Sie uns unter: +49 171 9345193\n\nMBO Tech IT\n${process.env.APP_URL ?? "https://mbo-tech-it.de"}`,
|
||||
html,
|
||||
},
|
||||
`Anfragebestätigung ${data.email}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendeKontaktEmail(
|
||||
data: KontaktEmailData
|
||||
): Promise<{ sent: boolean; queued: boolean }> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue