'Nicht angemeldet']); exit; } try { $templetid = $_POST['templetid'] ?? ''; $anfrageid = (int)($_POST['anfrageid'] ?? 0); if ($templetid === '' || $anfrageid <= 0) { throw new RuntimeException('Fehlende Parameter'); } // URL aus config-Tabelle holen (sicher, unabhängig von globalen Variablen) $stmt = $pdo->query("SELECT anfragebestaetigung FROM config LIMIT 1"); $anfragebestaetigung = (string)$stmt->fetchColumn(); if ($anfragebestaetigung === '') { throw new RuntimeException('Config anfragebestaetigung ist leer'); } $result = renderTemplateForAnfrage( $pdo, $anfrageid, $templetid, $anfragebestaetigung, // aus config [ // optional: // '%TERMINZEITVORGABE%' => $Zeitanzeige, ], false // CP1252 nur wenn nötig ); echo json_encode([ 'betreff' => $result['betreff'], 'body' => $result['body'] ]); } catch (Throwable $e) { // Interne Meldungen nur ins Log - sie verraten sonst Tabellen-, // Spalten- und Datensatznamen an den Aufrufer. error_log('mailtemplate.php: ' . $e->getMessage()); http_response_code(500); echo json_encode([ 'error' => 'Die Vorlage konnte nicht geladen werden.' ]); }