From 2a910847372d43a9db8935ced2549e932898f778 Mon Sep 17 00:00:00 2001 From: MBO-Tech-IT Date: Tue, 28 Apr 2026 09:12:48 +0200 Subject: [PATCH] feat: send confirmation email to contact form submitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Schickt nach eingehender Anfrage automatisch eine Bestätigungsmail an den Anfragenden mit Betreff, Dankestext und direkter Telefonnummer. Co-Authored-By: Claude Sonnet 4.6 --- app/api/contact/route.ts | 6 +++++- lib/mailer.ts | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/app/api/contact/route.ts b/app/api/contact/route.ts index 5b47398..0660890 100644 --- a/app/api/contact/route.ts +++ b/app/api/contact/route.ts @@ -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` + diff --git a/lib/mailer.ts b/lib/mailer.ts index 11a355a..a147791 100644 --- a/lib/mailer.ts +++ b/lib/mailer.ts @@ -115,6 +115,52 @@ export async function sendeRegistrierungsBestaetigung( ); } +export async function sendeAnfrageBestaetigung(data: { + name: string; + email: string; + betreff: string; +}): Promise { + const html = ` + + + + +
+

MBO Tech IT

+

Anfrage erhalten

+
+
+

Vielen Dank für Ihre Anfrage, ${data.name}!

+

+ Ihre Anfrage zum Thema „${data.betreff}" ist bei uns eingegangen. + Wir melden uns schnellstmöglich bei Ihnen. +

+

+ Bei dringenden Anliegen erreichen Sie uns direkt unter:
+ +49 171 9345193 +

+
+

Betreff: ${data.betreff}

+
+
+
+

MBO Tech IT · ${process.env.APP_URL ?? "https://mbo-tech-it.de"}

+
+ +`; + + 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 }> {