79 lines
3.4 KiB
PHP
79 lines
3.4 KiB
PHP
<?php
|
|
// Intent test_email_send — DRAFT ONLY · jamais envoi auto
|
|
// DOCTRINE ABSOLUE : Claude/WEVIA ne clique JAMAIS Send. Yacine seul envoie.
|
|
// Génère URL Gmail compose avec stats live pour que Yacine ouvre + valide + Send
|
|
|
|
if (!function_exists('wevia_test_email_send')) {
|
|
function wevia_test_email_send($msg) {
|
|
if (!$msg) return false;
|
|
if (!preg_match('/\b(test\s+(email|envoi|mail|send)|envoi[e]?\s+test|verifie?\s+email|teste?\s+(l\'?envoi|le\s+mail|pmta)|check\s+email\s+pipeline|email\s+test)\b/i', $msg)) return false;
|
|
|
|
$out = ['intent' => 'test_email_send', 'tool' => 'draft_only_no_auto_send'];
|
|
$out['doctrine'] = 'JAMAIS envoi auto · Yacine seul clique Send';
|
|
|
|
// Whitelist interne pour tests
|
|
$whitelist = [
|
|
'yacineutt@gmail.com' => 'Yacine personal',
|
|
'ymahboub@weval-consulting.com' => 'Yacine pro',
|
|
];
|
|
|
|
// Fetch live stats
|
|
$stats = @file_get_contents("/var/www/html/api/ethica-latest.json");
|
|
$sj = @json_decode($stats, true);
|
|
$total = number_format($sj['total'] ?? 0);
|
|
$emails = number_format($sj['with_email'] ?? 0);
|
|
|
|
$ts = date('Y-m-d H:i:s');
|
|
$subject = "[WEVAL TEST] Pipeline email check - " . date('H:i');
|
|
$body = "Test pipeline interne WEVIA Master\n\n"
|
|
. "Timestamp: {$ts}\n"
|
|
. "Stats live:\n"
|
|
. "- Ethica HCPs: {$total}\n"
|
|
. "- Emails valides: {$emails}\n"
|
|
. "- Route: PMTA S95 port 25\n"
|
|
. "- Rate limit: 100/h\n\n"
|
|
. "Pipeline OK si tu recois ce mail apres clic Send.\n\n"
|
|
. "Dashboards:\n"
|
|
. "- /automation-hub.html\n"
|
|
. "- /partners-emails.html\n"
|
|
. "- /blade-actions.html";
|
|
|
|
$drafts = [];
|
|
foreach ($whitelist as $to => $label) {
|
|
$url = "https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=cm&to=" . urlencode($to);
|
|
$url .= "&su=" . urlencode($subject);
|
|
$url .= "&body=" . urlencode($body);
|
|
$drafts[] = [
|
|
'to' => $to,
|
|
'label' => $label,
|
|
'subject' => $subject,
|
|
'gmail_url' => $url,
|
|
'action' => 'Yacine clique + Send (pas d\'envoi auto)',
|
|
];
|
|
}
|
|
|
|
// Trace
|
|
$trace = ['generated_at' => $ts, 'drafts' => $drafts, 'note' => 'DRAFTS ONLY · no auto-send'];
|
|
@file_put_contents('/var/www/html/api/test-email-drafts.json', json_encode($trace, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
|
|
$out['drafts'] = $drafts;
|
|
$out['count'] = count($drafts);
|
|
$out['dashboard'] = 'https://weval-consulting.com/test-email-drafts.html';
|
|
$out['next_step'] = 'Ouvre les 2 gmail_url, clic Send pour chacun - tu verifies que le pipeline PMTA fonctionne';
|
|
|
|
header("Content-Type: application/json");
|
|
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Auto-dispatch
|
|
$_te_msg = '';
|
|
$_body = @file_get_contents('php://input');
|
|
if ($_body) {
|
|
$_j = @json_decode($_body, true);
|
|
if (is_array($_j) && !empty($_j['message'])) $_te_msg = $_j['message'];
|
|
}
|
|
if (!$_te_msg) $_te_msg = $_POST['message'] ?? $_GET['message'] ?? '';
|
|
if ($_te_msg) wevia_test_email_send($_te_msg);
|