This commit is contained in:
Lizandro Guarnizo
2026-04-25 14:54:19 -05:00
parent bbf34d08d0
commit 2228818c85
4 changed files with 204 additions and 2 deletions
+8
View File
@@ -273,6 +273,14 @@ class CorreoImapService
// Eliminar líneas de cabecera de parte MIME (Content-Type, etc.)
$body = preg_replace('/^(Content-[^\r\n]+\r?\n)+/mi', '', $body);
// Si el cuerpo contiene HTML, convertir bloques estructurales a saltos
// de línea y luego quitar todas las etiquetas para obtener texto plano
if (preg_match('/<[a-z][\s>]/i', $body)) {
$body = preg_replace('/<(br\s*\/?|\/p|\/div|\/tr|\/li)>/i', "\n", $body);
$body = strip_tags($body);
$body = html_entity_decode($body, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
// Normalizar saltos de línea
$body = str_replace(["\r\n", "\r"], "\n", $body);