Task #10: Send automatic confirmation email to contact form submitters
After a visitor submits the contact form, Brevo now sends two emails: 1. The existing notification to jh@unixweb.de with the message details 2. A new confirmation email to the sender's address The confirmation email: - Is sent from "Joachim Hummel <jh@unixweb.de>" - Addresses the sender by name - Thanks them and sets response-time expectations (1-2 Werktage) - Includes both plain-text and HTML versions - Is logged separately via req.log.info for observability If either email fails, the entire request returns a 500 error (atomic behavior — both succeed or neither does from the user's perspective). File changed: - artifacts/api-server/src/routes/contact.ts Also ran `pnpm --filter @workspace/api-spec run codegen` to fix a pre-existing typecheck failure caused by stale generated lib output. Typecheck passes cleanly after codegen. Replit-Task-Id: a5d51157-6bd1-48c7-ba04-68e7d951eeab
This commit is contained in:
@@ -50,6 +50,27 @@ router.post("/contact", async (req, res) => {
|
||||
});
|
||||
|
||||
req.log.info({ to: "jh@unixweb.de", from: email }, "Contact message sent via Brevo");
|
||||
|
||||
await brevo.transactionalEmails.sendTransacEmail({
|
||||
sender: { name: "Joachim Hummel", email: "jh@unixweb.de" },
|
||||
to: [{ email, name }],
|
||||
subject: "Ihre Anfrage ist angekommen – vielen Dank!",
|
||||
textContent: [
|
||||
`Hallo ${name},`,
|
||||
"",
|
||||
"vielen Dank für Ihre Nachricht! Ich habe Ihre Anfrage erhalten und melde mich in der Regel innerhalb von 1–2 Werktagen bei Ihnen.",
|
||||
"",
|
||||
"Mit freundlichen Grüßen",
|
||||
"Joachim Hummel",
|
||||
].join("\n"),
|
||||
htmlContent: `
|
||||
<p>Hallo ${escapeHtml(name)},</p>
|
||||
<p>vielen Dank für Ihre Nachricht! Ich habe Ihre Anfrage erhalten und melde mich in der Regel innerhalb von <strong>1–2 Werktagen</strong> bei Ihnen.</p>
|
||||
<p>Mit freundlichen Grüßen<br />Joachim Hummel</p>
|
||||
`,
|
||||
});
|
||||
|
||||
req.log.info({ to: email }, "Confirmation email sent to sender via Brevo");
|
||||
res.json({ success: true, message: "Ihre Nachricht wurde erfolgreich gesendet." });
|
||||
} catch (err) {
|
||||
req.log.error({ err }, "Failed to send contact email via Brevo");
|
||||
|
||||
Reference in New Issue
Block a user