Reverted to old rsvp-submit.php
This commit is contained in:
+8
-47
@@ -9,17 +9,6 @@ if (!empty($_POST['website'])) {
|
||||
exit; // silently drop bot submission
|
||||
}
|
||||
|
||||
/* Load environment variables (your Option 1) */
|
||||
$env = parse_ini_file('/etc/wedding.env');
|
||||
|
||||
$smtpUser = $env['SMTP_USER'] ?? null;
|
||||
$smtpPass = $env['SMTP_PASS'] ?? null;
|
||||
$smtpHost = $env['SMTP_HOST'] ?? 'posteo.de';
|
||||
|
||||
if (!$smtpUser || !$smtpPass) {
|
||||
exit("Server misconfiguration (missing SMTP credentials)");
|
||||
}
|
||||
|
||||
/* Safely read form fields */
|
||||
$first_name = htmlspecialchars($_POST['first_name'] ?? '');
|
||||
$last_name = htmlspecialchars($_POST['last_name'] ?? '');
|
||||
@@ -31,47 +20,19 @@ if (!$first_name || !$last_name) {
|
||||
exit("Missing required fields");
|
||||
}
|
||||
|
||||
/* Build email content */
|
||||
/* Email setup */
|
||||
$to = "hochzeit@markinstefan.xyz";
|
||||
$subject = "New Wedding RSVP from $first_name $last_name";
|
||||
|
||||
$body = "New RSVP received:\n\n";
|
||||
$body .= "Name: $first_name $last_name\n";
|
||||
$body .= "Drinks: $drinks\n";
|
||||
$body .= "Allergies: $allergies\n";
|
||||
$body .= "Time: " . date("Y-m-d H:i:s") . "\n";
|
||||
$message = "Name: $first_name $last_name\n";
|
||||
$message .= "Drinks: $drinks\n";
|
||||
$message .= "Allergies: $allergies\n";
|
||||
|
||||
/* Load PHPMailer */
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
$headers = "From: no-reply@markinstefan.xyz\r\n";
|
||||
$headers .= "Reply-To: no-reply@markinstefan.xyz\r\n";
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
/* SMTP config */
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $smtpHost;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $smtpUser;
|
||||
$mail->Password = $smtpPass;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = 587;
|
||||
|
||||
/* Email headers */
|
||||
$mail->setFrom($smtpUser, 'Wedding RSVP');
|
||||
$mail->addAddress($to);
|
||||
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
|
||||
$mail->send();
|
||||
/* Send mail */
|
||||
mail($to, $subject, $message, $headers);
|
||||
|
||||
echo "Thank you! Your RSVP has been sent.";
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("RSVP mail failed: " . $mail->ErrorInfo);
|
||||
exit("Sorry, something went wrong sending your RSVP.");
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user