$thesis['identifier'] ?? '', 'Titre' => $thesis['title'] ?? '', 'Sous-titre' => $thesis['subtitle'] ?? '', 'Auteur·ice(s)'=> $thesis['authors'] ?? '', 'Année' => $thesis['year'] ?? '', 'Orientation' => $thesis['orientation'] ?? '', 'Atelier pluridisciplinaire' => $thesis['ap_program'] ?? '', 'Finalité' => $thesis['finality_type'] ?? '', 'Synopsis' => $thesis['synopsis'] ?? '', 'Langue(s)' => $thesis['languages'] ?? '', 'Format(s)' => $thesis['formats'] ?? '', 'Mots-clés' => $thesis['keywords'] ?? '', 'Promoteur·ice(s)' => $thesis['jury_promoteurs'] ?? '', 'Président·e du jury' => $thesis['jury_president'] ?? '', 'Lecteurs·rices' => $thesis['jury_lecteurs'] ?? '', 'Durée / Taille' => $thesis['file_size_info'] ?? '', 'Lien' => $thesis['baiu_link'] ?? '', 'Type d\'accès' => $thesis['access_type'] ?? '', 'Licence' => $thesis['license_type'] ?? '', ]; foreach ($fields as $label => $value) { $v = $value === '' ? '–' : htmlspecialchars((string)$value); $rows .= "" . htmlspecialchars($label) . "" . "{$v}\n"; } return <<

Merci — ton TFE a bien été enregistré 🎉

Voici un récapitulatif de ta soumission. Tu n'as pas besoin de répondre à cet e-mail.

{$rows}

Plateforme xamxam · erg Bruxelles

HTML; } /** * Send a confirmation e-mail for a given thesis. * * @param Database $db * @param int $thesisId * @param array $postData Raw $_POST (must contain 'confirmation_email') * @return bool True when sent, false otherwise */ public static function sendConfirmation( Database $db, int $thesisId, array $postData ): bool { // ── 1. Read e-mail from confirmation field ───────────────────────── $to = trim($postData['confirmation_email'] ?? ''); if ($to === '' || filter_var($to, FILTER_VALIDATE_EMAIL) === false) { error_log('[StudentEmail] No valid confirmation e-mail — skipping thesis #' . $thesisId); return false; } // ── 2. Check SMTP config ──────────────────────────────────────────── if (!SmtpRelay::isConfigured($db)) { error_log('[StudentEmail] SMTP not configured — skipping thesis #' . $thesisId); return false; } // ── 3. Fetch thesis data ──────────────────────────────────────────── $thesis = $db->getThesis($thesisId); if (!$thesis) { error_log('[StudentEmail] Thesis #' . $thesisId . ' not found after creation'); return false; } // ── 4. Send ───────────────────────────────────────────────────────── $subject = 'Merci — ton TFE a bien été enregistré'; $htmlBody = self::buildHtml($thesis); try { $result = SmtpRelay::send($db, $to, $subject, $htmlBody); } catch (SmtpSendException $e) { // Confirmation email failure must not abort the successful submission. error_log("[StudentEmail] SMTP error sending to {$to} for thesis #{$thesisId}: " . $e->getMessage()); return false; } if ($result) { error_log("[StudentEmail] Confirmation sent to {$to} for thesis #{$thesisId}"); } else { error_log("[StudentEmail] Failed to send to {$to} for thesis #{$thesisId}"); } return $result; } }