Files
Thies Mueller bbcfaf32f7 initial commit
2026-04-25 23:00:38 +02:00

126 lines
3.6 KiB
PHP

<?php
$config = require 'mailconfig.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
function buildHtmlMail($data) {
$rows = '';
foreach ($data as $key => $value) {
if (!in_array($key, ['captcha','captcha_result','website'])) {
$rows .= "
<tr>
<td style='padding:10px;border:1px solid #374151;color:#9ca3af;background:#1f2937;'>
" . ucfirst($key) . "
</td>
<td style='padding:10px;border:1px solid #374151;color:#f9fafb;background:#111827;'>
" . htmlspecialchars($value) . "
</td>
</tr>";
}
}
return "
<div style='background:#0f172a;padding:20px;font-family:Arial,sans-serif;color:#f9fafb;'>
<div style='max-width:600px;margin:0 auto;background:#111827;border-radius:12px;padding:24px;'>
<h2 style='color:#ffffff;margin-bottom:20px;'>
Neue Fotobox Anfrage
</h2>
<table style='width:100%;border-collapse:collapse;margin-bottom:20px;'>
$rows
</table>
<hr style='border:0;border-top:1px solid #374151;margin:20px 0;'>
<div style='font-size:12px;color:#9ca3af;line-height:1.6;'>
Thies Mueller Service Solutions<br>
Schwarzenbergstr. 70, 21073 Hamburg<br><br>
Ust.ID: DE340124938
</div>
</div>
</div>";
}
function sendMail($data, $config) {
$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->Host = $config['smtp_host'];
$mail->SMTPAuth = true;
$mail->Username = $config['smtp_user'];
$mail->Password = $config['smtp_pass'];
$mail->SMTPSecure = 'tls';
$mail->Port = $config['smtp_port'];
$mail->setFrom($config['from'], $config['from_name']);
$html = buildHtmlMail($data);
$mail->addAddress($config['receipient']);
$mail->addReplyTo($data['email']);
$mail->isHTML(true);
$mail->Subject = 'Neue Fotobox Anfrage';
$mail->Body = $html;
$mail->AltBody = strip_tags($html);
$mail->send();
$mail->clearAddresses();
$mail->clearReplyTos();
$mail->addAddress($data['email']);
$mail->addReplyTo($config['receipient']);
$mail->Subject = 'Deine Anfrage bei'.$config['company_name'];
$mail->Body = "<div style='font-family:sans-serif;background:#111;color:#fff;padding:20px;'>
<h2>Danke für deine Anfrage</h2>
<p>Wir haben deine Anfrage erhalten und melden uns zeitnah.</p>
<hr>
$html
</div>";
$mail->AltBody = 'Danke für deine Anfrage';
$mail->send();
}
$status = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['website'])) {
die('Spam erkannt');
}
if ($_POST['captcha'] != $_POST['captcha_result']) {
$status = 'error';
} else {
try {
sendMail($_POST, $config);
header('Location: success.html');
exit;
} catch (Exception $e) {
$status = 'error';
}
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fehler</title>
<link href="/assets/tailwind.css" rel="stylesheet">
</head>
<body class="bg-gray-900 text-white flex items-center justify-center min-h-screen">
<div class="bg-gray-800 p-8 rounded-2xl text-center">
<h1 class="text-2xl mb-4">Fehler beim Senden</h1>
<a href="contact.html" class="bg-blue-600 px-4 py-2">Zurück</a>
</div>
</body>
</html>