diff --git a/app/mail/page.tsx b/app/mail/page.tsx
index 830c70d..23a4097 100644
--- a/app/mail/page.tsx
+++ b/app/mail/page.tsx
@@ -41,22 +41,31 @@ interface Email {
category: string;
}
-// Update MIME decoding function for better formatting
+// Improve MIME decoding function
const decodeMimeContent = (content: string) => {
try {
- // Remove MIME headers and metadata
- const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, '')
- .replace(/---InfomaniakPhpMail.*?Content-Transfer-Encoding:.*?\n/g, '')
- .replace(/=C2=A0/g, ' ') // Replace non-breaking spaces
- .replace(/=\n/g, '') // Remove soft line breaks
- .replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
- .replace(/\[IMG:.*?\]/g, '') // Remove image placeholders
- .replace(/\[LINK:\s*(.*?)\s*\]/g, '$1') // Clean up links
- .replace(/\*([^*]+)\*/g, '$1') // Remove asterisks
- .replace(/\s+/g, ' ') // Normalize whitespace
- .trim();
+ // Extract the actual content after headers
+ const contentMatch = content.match(/charset="utf-8"\s*([\s\S]*?)(?=\s*(?:\[LINK:|$))/);
+ if (!contentMatch) return content;
- return contentWithoutHeaders;
+ let cleanContent = contentMatch[1]
+ // Remove MIME headers and metadata
+ .replace(/^.*?Content-Type:.*?\n\n/s, '')
+ .replace(/---InfomaniakPhpMail.*?Content-Transfer-Encoding:.*?\n/g, '')
+ // Clean up special characters
+ .replace(/=C2=A0/g, ' ')
+ .replace(/=\n/g, '')
+ .replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
+ // Remove formatting markers
+ .replace(/\[IMG:.*?\]/g, '')
+ .replace(/\*([^*]+)\*/g, '$1')
+ // Clean up links
+ .replace(/\[ LINK: (.*?) \]/g, '$1')
+ // Normalize whitespace
+ .replace(/\s+/g, ' ')
+ .trim();
+
+ return cleanContent;
} catch (error) {
console.error('Error decoding MIME content:', error);
return content;
@@ -309,11 +318,11 @@ export default function MailPage() {
{/* Sidebar */}
- {/* Mail Title */}
+ {/* Courrier Title */}
@@ -330,180 +339,188 @@ export default function MailPage() {
- {/* Accounts Section */}
-
-
-
- {accountsDropdownOpen && (
-
- {/* All Accounts Option */}
-
+ {/* Accounts Section with Scrollable Content */}
+
+
+
+
+ {accountsDropdownOpen && (
+
+ {/* All Accounts Option */}
+
- {/* Mail Accounts List */}
- {accounts.map(account => (
-
-
- )}
-
-
- {/* Navigation */}
-
+
+
+ {/* Account Actions Dropdown */}
+ {showAccountActions === account.id && (
+
+ {
+ const newName = prompt('Enter new account name:', account.name);
+ if (newName) handleEditAccount(account.id, newName);
+ setShowAccountActions(null);
+ }}
+ >
+
+ Modify Account
+
+ {
+ setDeleteType('account');
+ setItemToDelete(account.id);
+ setShowDeleteConfirm(true);
+ setShowAccountActions(null);
+ }}
+ >
+
+ Remove Account
+
+
+ )}
+
+ ))}
+
+ {/* Add Account Button */}
+
+
+ Add Account
+
+
+ )}
+
+
+ {/* Scrollable Navigation */}
+
+
+
+
{/* Main content */}