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) |
function sendEmailWithBrevo($to, $subject, $message) |
||||
{ |
{ |
||||
@ -269,14 +269,14 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||||
|
|
||||
$email = \Config\Services::email(); |
$email = \Config\Services::email(); |
||||
|
|
||||
// Configuration Brevo depuis le fichier .env |
// ✅ Configuration Brevo hardcodée (pas besoin du .env) |
||||
$config = [ |
$config = [ |
||||
'protocol' => env('email.protocol', 'smtp'), |
'protocol' => 'smtp', |
||||
'SMTPHost' => env('email.SMTPHost', 'smtp-relay.brevo.com'), |
'SMTPHost' => 'smtp-relay.brevo.com', |
||||
'SMTPUser' => env('email.SMTPUser'), |
'SMTPUser' => '[email protected]', |
||||
'SMTPPass' => env('email.SMTPPass'), |
'SMTPPass' => '2JT0KhZOfgSVQk9D', |
||||
'SMTPPort' => env('email.SMTPPort', 587), |
'SMTPPort' => 587, |
||||
'SMTPCrypto' => env('email.SMTPCrypto', 'tls'), |
'SMTPCrypto' => 'tls', |
||||
'mailType' => 'html', |
'mailType' => 'html', |
||||
'charset' => 'utf-8', |
'charset' => 'utf-8', |
||||
'newline' => "\r\n", |
'newline' => "\r\n", |
||||
@ -288,11 +288,8 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||||
|
|
||||
$email->initialize($config); |
$email->initialize($config); |
||||
|
|
||||
// Utilisation de l'email configuré dans .env |
// ✅ Configuration expéditeur hardcodée |
||||
$fromEmail = env('email.fromEmail', '[email protected]'); |
$email->setFrom('[email protected]', 'Système Motorbike - Alertes'); |
||||
$fromName = env('email.fromName', 'Système Motorbike - Alertes'); |
|
||||
|
|
||||
$email->setFrom($fromEmail, $fromName); |
|
||||
$email->setTo($to); |
$email->setTo($to); |
||||
$email->setSubject($subject); |
$email->setSubject($subject); |
||||
$email->setMessage($message); |
$email->setMessage($message); |
||||
@ -305,11 +302,11 @@ function sendEmailWithBrevo($to, $subject, $message) |
|||||
return false; |
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; |
return true; |
||||
|
|
||||
} catch (\Exception $e) { |
} 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()); |
log_message('error', "Stack trace: " . $e->getTraceAsString()); |
||||
return false; |
return false; |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue