From aa57f64e4f744fed3017c244c85cde60bf175486 Mon Sep 17 00:00:00 2001 From: Lizandro Date: Wed, 15 Jul 2026 04:07:19 +0000 Subject: [PATCH] debug: show mail error message in Telegram for diagnosis --- app/Services/TelegramBotService.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Services/TelegramBotService.php b/app/Services/TelegramBotService.php index 47f4753..6f71406 100644 --- a/app/Services/TelegramBotService.php +++ b/app/Services/TelegramBotService.php @@ -388,12 +388,12 @@ class TelegramBotService $codigo = (string) random_int(100000, 999999); Cache::put("chat_otp_{$contact->id}", $codigo, now()->addMinutes(10)); - $mailEnviado = true; + $mailError = null; try { Mail::to($user->email)->send(new ChatOtpMail($codigo, $user->name)); } catch (\Throwable $e) { - $mailEnviado = false; - Log::warning('[TelegramOTP] Error enviando correo: ' . $e->getMessage()); + $mailError = $e->getMessage(); + Log::warning('[TelegramOTP] Error enviando correo: ' . $mailError); } $this->setState($chatId, [ @@ -404,13 +404,11 @@ class TelegramBotService $masked = $this->maskEmail($user->email); - if ($mailEnviado) { + if (! $mailError) { $this->send($chatId, "✉️ Te enviamos un código a `{$masked}`\n\nEscribe el código de 6 dígitos:"); } else { $this->send($chatId, - "✉️ Código generado para `{$masked}`\n\n" . - "⚠️ Hubo un problema enviando el correo. Revisa tu bandeja o escribe /cancelar para intentar de nuevo.\n\n" . - "Si lo recibiste, escribe el código de 6 dígitos:" + "⚠️ Error enviando correo a `{$masked}`\n\n`{$mailError}`\n\nContacta al administrador." ); } }