<?php
$baseUrl = "http://desktop-t3pjdpe/ugo";
$emailUrls = [
    "$baseUrl/email_box_open?recipient=1", // Vlasnik
    "$baseUrl/email_box_open?recipient=2"  // Knjigovodstvo
];

foreach ($emailUrls as $emailUrl) {
    $ch = curl_init($emailUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    $response = curl_exec($ch);
    curl_close($ch);

    if (strpos($response, 'E-mail poslan') === false) {
        die("Greška prilikom slanja e-maila");
    }
    echo "E-mail poslan za " . (strpos($emailUrl, 'recipient=1') ? 'Vlasnik' : 'Knjigovodstvo') . "<br>";
}
?>
