authenticate(); $EMAIL_ADDRESS = 'hamzaayed@intaleqapp.com'; // 2. استقبال البيانات وتطهيرها (Sanitization) $passengerName = htmlspecialchars(filterRequest('name') ?? 'User', ENT_QUOTES, 'UTF-8'); $passengerEmail = filter_var(filterRequest('email'), FILTER_SANITIZE_EMAIL); $passengerPhone = htmlspecialchars(filterRequest('phone') ?? '', ENT_QUOTES, 'UTF-8'); $fee = floatval(filterRequest('fee') ?? 0); $startNameLocation = htmlspecialchars(filterRequest('startNameLocation') ?? '', ENT_QUOTES, 'UTF-8'); $endNameLocation = htmlspecialchars(filterRequest('endNameLocation') ?? '', ENT_QUOTES, 'UTF-8'); $timeOfTrip = htmlspecialchars(filterRequest('timeOfTrip') ?? date('Y-m-d H:i:s'), ENT_QUOTES, 'UTF-8'); if (!$passengerEmail || !filter_var($passengerEmail, FILTER_VALIDATE_EMAIL)) { jsonError("Invalid email address"); } $SIRO_SMTP_PASSWORD = getenv('SIRO_SMTP_PASSWORD'); // بناء محتوى الإيميل بتصميم عصري وبريميوم $bodyEmail = "

SIRO

Your journey, our priority

Hello, $passengerName!

Thank you for choosing SIRO. Your trip has been successfully confirmed. Here is your digital receipt:

From: $startNameLocation
To: $endNameLocation
Date & Time: $timeOfTrip
Phone: $passengerPhone
Total Amount
$$fee

If you have any questions, feel free to contact our support team at any time.

"; $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.hostinger.com'; $mail->SMTPAuth = true; $mail->Username = $EMAIL_ADDRESS; $mail->Password = $SIRO_SMTP_PASSWORD; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->setFrom($EMAIL_ADDRESS, 'SIRO'); $mail->addAddress($passengerEmail, $passengerName); $mail->isHTML(true); $mail->Subject = 'Your SIRO Trip Details'; $mail->Body = $bodyEmail; $mail->send(); jsonSuccess(null, "Email sent successfully"); } catch (Exception $e) { jsonError("Failed to send email: " . $mail->ErrorInfo); }