1 changed files with 12 additions and 15 deletions
@ -260,7 +260,7 @@ function checkAndConvertCompletedAvances() |
|||
|
|||
|
|||
/** |
|||
* Envoyer un email via Brevo |
|||
* ✅ Envoyer un email via Brevo (configuration hardcodée pour éviter dépendance .env) |
|||
*/ |
|||
function sendEmailWithBrevo($to, $subject, $message) |
|||
{ |
|||
@ -269,14 +269,14 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||
|
|||
$email = \Config\Services::email(); |
|||
|
|||
// Configuration Brevo depuis le fichier .env |
|||
// ✅ Configuration Brevo hardcodée (pas besoin du .env) |
|||
$config = [ |
|||
'protocol' => env('email.protocol', 'smtp'), |
|||
'SMTPHost' => env('email.SMTPHost', 'smtp-relay.brevo.com'), |
|||
'SMTPUser' => env('email.SMTPUser'), |
|||
'SMTPPass' => env('email.SMTPPass'), |
|||
'SMTPPort' => env('email.SMTPPort', 587), |
|||
'SMTPCrypto' => env('email.SMTPCrypto', 'tls'), |
|||
'protocol' => 'smtp', |
|||
'SMTPHost' => 'smtp-relay.brevo.com', |
|||
'SMTPUser' => '[email protected]', |
|||
'SMTPPass' => '2JT0KhZOfgSVQk9D', |
|||
'SMTPPort' => 587, |
|||
'SMTPCrypto' => 'tls', |
|||
'mailType' => 'html', |
|||
'charset' => 'utf-8', |
|||
'newline' => "\r\n", |
|||
@ -288,11 +288,8 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||
|
|||
$email->initialize($config); |
|||
|
|||
// Utilisation de l'email configuré dans .env |
|||
$fromEmail = env('email.fromEmail', '[email protected]'); |
|||
$fromName = env('email.fromName', 'Système Motorbike - Alertes'); |
|||
|
|||
$email->setFrom($fromEmail, $fromName); |
|||
// ✅ Configuration expéditeur hardcodée |
|||
$email->setFrom('[email protected]', 'Système Motorbike - Alertes'); |
|||
$email->setTo($to); |
|||
$email->setSubject($subject); |
|||
$email->setMessage($message); |
|||
@ -305,11 +302,11 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||
return false; |
|||
} |
|||
|
|||
log_message('info', "Email envoyé avec succès via Brevo à: {$to}"); |
|||
log_message('info', "✅ Email envoyé avec succès via Brevo à: {$to}"); |
|||
return true; |
|||
|
|||
} catch (\Exception $e) { |
|||
log_message('error', "Exception email Brevo à {$to}: " . $e->getMessage()); |
|||
log_message('error', "❌ Exception email Brevo à {$to}: " . $e->getMessage()); |
|||
log_message('error', "Stack trace: " . $e->getTraceAsString()); |
|||
return false; |
|||
} |
|||
|
|||
Loading…
Reference in new issue