From d0136a32a568083588c11fcf741a0daf24c77e02 Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 26 Apr 2025 10:56:09 +0200 Subject: [PATCH] panel 2 courier api restore --- components/email/ComposeEmail.tsx | 4 ++++ lib/services/email-service.ts | 35 +++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/components/email/ComposeEmail.tsx b/components/email/ComposeEmail.tsx index 1342c175..70b9da2d 100644 --- a/components/email/ComposeEmail.tsx +++ b/components/email/ComposeEmail.tsx @@ -198,11 +198,13 @@ export default function ComposeEmail({ // First try the html field which should contain the raw HTML if (initialEmail.html && initialEmail.html.trim()) { console.log('Using HTML content for forward'); + // Preserve the HTML exactly as-is without any wrapper divs that could break styles originalContent = initialEmail.html; } // Then try the content field else if (initialEmail.content && initialEmail.content.trim()) { console.log('Using content field for forward'); + // Preserve the content exactly as-is originalContent = initialEmail.content; } // Fall back to text with styling if available @@ -219,9 +221,11 @@ export default function ComposeEmail({ // Preserve all original structure by wrapping, not modifying the original content const forwardedContent = ` ${headerHtml} +
${originalContent}
+ `; console.log('Setting body with forwarded content'); diff --git a/lib/services/email-service.ts b/lib/services/email-service.ts index 72e3ea20..a1b05022 100644 --- a/lib/services/email-service.ts +++ b/lib/services/email-service.ts @@ -665,17 +665,30 @@ export function formatEmailForReplyOrForward( .map(addr => `${addr.name} <${addr.address}>`) .join(', '); } else if (type === 'forward') { - formattedContent = ` -
-

---------- Forwarded message ---------

-

From: ${decoded.from || ''}

-

Date: ${formatDate(decoded.date ? new Date(decoded.date) : null)}

-

Subject: ${decoded.subject || ''}

-

To: ${decoded.to || ''}

-
- ${decoded.html || `
${decoded.text || ''}
`} -
- `; + // Forward case doesn't need to set recipients + to = ''; + + // Instead, we format the content differently + const formattedDate = email.date ? new Date(email.date).toLocaleString() : ''; + const fromText = email.from.map(f => f.name ? `${f.name} <${f.address}>` : f.address).join(', '); + const toText = email.to.map(t => t.name ? `${t.name} <${t.address}>` : t.address).join(', '); + + // Return specialized body for forward + return { + to: '', + subject, + body: ` +
+

---------- Forwarded message ---------

+

From: ${fromText}

+

Date: ${formattedDate}

+

Subject: ${email.subject || ''}

+

To: ${toText}

+
+ ${email.html || email.text ? (email.html || `
${email.text || ''}
`) : '

No content available

'} +
+ ` + }; } // Format the email body with quote