Initial upload of BB-Apartment 2026 website.
Adds the complete Next.js website including i18n routing, house and apartment pages, Beds24 v2 integration for live availability/pricing, Stripe checkout, contact forms, Docker setup and deployment docs. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
232770afe7
commit
2b24334bfa
@@ -0,0 +1,63 @@
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
export interface ContactMessage {
|
||||
email: string;
|
||||
message: string;
|
||||
name?: string;
|
||||
/** Optional context, e.g. the search dates that had no availability. */
|
||||
context?: string;
|
||||
}
|
||||
|
||||
function getTransport() {
|
||||
const { SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD } = process.env;
|
||||
if (!SMTP_HOST || !SMTP_USER || !SMTP_PASSWORD) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return nodemailer.createTransport({
|
||||
host: SMTP_HOST,
|
||||
port: Number(SMTP_PORT) || 587,
|
||||
secure: Number(SMTP_PORT) === 465,
|
||||
auth: {
|
||||
user: SMTP_USER,
|
||||
pass: SMTP_PASSWORD,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendContactMessage(data: ContactMessage): Promise<void> {
|
||||
const transport = getTransport();
|
||||
const to = process.env.CONTACT_INBOX_EMAIL || "info@bb-apartment.de";
|
||||
const from = process.env.SMTP_FROM || "noreply@bb-apartment.de";
|
||||
|
||||
const subject = `Neue Kontaktanfrage von ${data.name || data.email}`;
|
||||
const text = [
|
||||
data.context ? `Kontext: ${data.context}` : null,
|
||||
`Name: ${data.name || "-"}`,
|
||||
`E-Mail: ${data.email}`,
|
||||
"",
|
||||
data.message,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
|
||||
if (!transport) {
|
||||
// No SMTP configured yet (development) — log instead of failing so the
|
||||
// form still "works" locally.
|
||||
console.log("[contact] SMTP not configured, would have sent:", {
|
||||
to,
|
||||
from,
|
||||
subject,
|
||||
text,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await transport.sendMail({
|
||||
to,
|
||||
from,
|
||||
replyTo: data.email,
|
||||
subject,
|
||||
text,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user