<?php
require_once __DIR__ . '/../includes/functions.php';
require_once __DIR__ . '/../includes/mj_email_helpers.php';
$limit = max(1, min(200, (int)($_GET['limit'] ?? 50)));
$result = mj_process_email_queue($limit);
if (PHP_SAPI !== 'cli') { header('Content-Type: application/json'); }
echo json_encode(['ok'=>true,'processed_limit'=>$limit] + $result, JSON_PRETTY_PRINT);
