fix: send internal notifications of email errors
This commit is contained in:
@@ -12,23 +12,29 @@ class EmailChannel
|
||||
{
|
||||
public function send(SendsEmail $notifiable, Notification $notification): void
|
||||
{
|
||||
$this->bootConfigs($notifiable);
|
||||
$recepients = $notifiable->getRecepients($notification);
|
||||
try {
|
||||
$this->bootConfigs($notifiable);
|
||||
$recepients = $notifiable->getRecepients($notification);
|
||||
ray($recepients);
|
||||
if (count($recepients) === 0) {
|
||||
throw new Exception('No email recipients found');
|
||||
}
|
||||
|
||||
if (count($recepients) === 0) {
|
||||
throw new Exception('No email recipients found');
|
||||
$mailMessage = $notification->toMail($notifiable);
|
||||
throw new Exception('EmailChannel is disabled');
|
||||
Mail::send(
|
||||
[],
|
||||
[],
|
||||
fn (Message $message) => $message
|
||||
->to($recepients)
|
||||
->subject($mailMessage->subject)
|
||||
->html((string)$mailMessage->render())
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
ray($e->getMessage());
|
||||
send_internal_notification("EmailChannel error: {$e->getMessage()}. Failed to send email to: " . implode(', ', $recepients) . " with subject: {$mailMessage->subject}");
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$mailMessage = $notification->toMail($notifiable);
|
||||
ray("Sending email to: " . implode(', ', $recepients) . " with subject: {$mailMessage->subject}");
|
||||
Mail::send(
|
||||
[],
|
||||
[],
|
||||
fn (Message $message) => $message
|
||||
->to($recepients)
|
||||
->subject($mailMessage->subject)
|
||||
->html((string)$mailMessage->render())
|
||||
);
|
||||
}
|
||||
|
||||
private function bootConfigs($notifiable): void
|
||||
|
||||
Reference in New Issue
Block a user