| Current Path : /home/happyrenas/find.myreco.online/v2/includes/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/happyrenas/find.myreco.online/v2/includes/mail_find.php |
<?php
declare(strict_types=1);
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
require_once __DIR__ . '/../PHPMailer-6.9.1/src/Exception.php';
require_once __DIR__ . '/../PHPMailer-6.9.1/src/PHPMailer.php';
require_once __DIR__ . '/../PHPMailer-6.9.1/src/SMTP.php';
if (!function_exists('nettoyerChamp')) {
function nettoyerChamp(?string $valeur): string
{
return trim((string) $valeur);
}
}
if (!function_exists('ecrireValeur')) {
function ecrireValeur(string $valeur): string
{
return htmlspecialchars($valeur, ENT_QUOTES, 'UTF-8');
}
}
if (!function_exists('afficherPageRetour')) {
function afficherPageRetour(string $titre, string $message, string $type = 'success', string $urlRetour = 'index.php'): void
{
$classe = ($type === 'success') ? 'alert-success' : 'alert-danger';
echo '<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>' . ecrireValeur($titre) . '</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="background:#f8f9fa;">
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card shadow-sm border-0 rounded-4">
<div class="card-body p-4 p-md-5">
<h1 class="h3 mb-4">' . ecrireValeur($titre) . '</h1>
<div class="alert ' . $classe . ' mb-4">' . $message . '</div>
<a href="' . ecrireValeur($urlRetour) . '" class="btn btn-primary rounded-pill px-4">Retour</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>';
exit;
}
}
if (!function_exists('envoyerMailFind')) {
function envoyerMailFind(
string $emailReplyTo,
string $nomReplyTo,
string $subject,
string $htmlBody,
string $textBody,
?string &$erreur = null
): bool {
try {
$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->Host = 'smtp.mail.ovh.net';
$mail->SMTPAuth = true;
$mail->Username = SMTP_USER;
$mail->Password = SMTP_PASS;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
$mail->setFrom(SMTP_USER, 'MyReco');
$mail->addAddress(ADMIN_EMAIL, 'Admin MyReco');
if (defined('EMAIL_BCC') && EMAIL_BCC !== '') {
$mail->addBCC(EMAIL_BCC);
}
if ($emailReplyTo !== '' && filter_var($emailReplyTo, FILTER_VALIDATE_EMAIL)) {
$mail->addReplyTo($emailReplyTo, $nomReplyTo);
}
$mail->Subject = $subject;
$mail->Body = $htmlBody;
$mail->AltBody = $textBody;
$mail->isHTML(true);
$mail->send();
return true;
} catch (Exception $e) {
$erreur = $mail->ErrorInfo ?: $e->getMessage();
return false;
}
}
}