From c518654da5e94a00dc2bd3d0ff4c466761e75d57 Mon Sep 17 00:00:00 2001 From: spetznas Date: Sat, 16 May 2026 23:45:24 +0200 Subject: [PATCH] Added UTF-8 support to rsvp-submit.php #2 --- static/rsvp-submit.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/static/rsvp-submit.php b/static/rsvp-submit.php index 6c922ae..37529af 100755 --- a/static/rsvp-submit.php +++ b/static/rsvp-submit.php @@ -3,7 +3,7 @@ require __DIR__ . '/vendor/autoload.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; -$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../'); // <-- root .env $dotenv->load(); $name = $_POST['name'] ?? 'No Name'; @@ -13,8 +13,10 @@ $allergies = $_POST['allergies'] ?? 'None'; $mail = new PHPMailer(true); try { - $mail->CharSet = 'UTF-8'; // <-- Make sure UTF-8 is used + $mail->CharSet = 'UTF-8'; $mail->isSMTP(); + $mail->SMTPDebug = 2; // debug mode + $mail->Debugoutput = 'html'; $mail->Host = $_ENV['SMTP_HOST']; $mail->SMTPAuth = true; $mail->Username = $_ENV['SMTP_USER']; @@ -26,16 +28,10 @@ try { $mail->addAddress($_ENV['TO_EMAIL']); $mail->Subject = "New Wedding RSVP from $name"; - if (!empty($_POST['email'])) { - $mail->addReplyTo($_POST['email'], $name); - } - - $body = "Name: $name\nDrinks: $drinks\nAllergies: $allergies\n"; - $mail->Body = $body; + $mail->Body = "Name: $name\nDrinks: $drinks\nAllergies: $allergies\n"; $mail->send(); echo 'RSVP submitted successfully.'; } catch (Exception $e) { echo "RSVP could not be sent. Mailer Error: {$mail->ErrorInfo}"; } -?>