Go to file
2025-04-27 10:25:20 +02:00
app courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
components courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
hooks courrier refactor 2025-04-26 22:44:53 +02:00
lib courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
node_modules courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
prisma carnet panel3 2025-04-20 17:23:48 +02:00
public Initial commit 2025-04-17 11:39:15 +02:00
scripts solve mail backend 11 2025-04-17 14:14:15 +02:00
styles Initial commit 2025-04-17 11:39:15 +02:00
types carnet panel contact 2025-04-20 21:50:30 +02:00
.DS_Store clean Navigation Bar 6 2025-04-17 15:43:41 +02:00
.env carnet panel3 2025-04-20 17:23:48 +02:00
.gitignore without logo 2025-04-25 17:41:20 +02:00
components.json Initial commit 2025-04-17 11:39:15 +02:00
DEPRECATED_FUNCTIONS.md courrier clean 2$ 2025-04-26 20:44:11 +02:00
docker-compose.yml Initial commit 2025-04-17 11:39:15 +02:00
Dockerfile Initial commit 2025-04-17 11:39:15 +02:00
keycloak-user-creation-workflow.json Initial commit 2025-04-17 11:39:15 +02:00
next-env.d.ts without logo 2025-04-25 17:41:20 +02:00
next.config.js compose mime 2025-04-25 09:25:04 +02:00
next.config.mjs session correction logout 3 rest 3 2025-04-18 14:13:54 +02:00
package-lock.json courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
package.json courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00
postcss.config.mjs Initial commit 2025-04-17 11:39:15 +02:00
README.md courrier clean 2$ 2025-04-26 20:47:03 +02:00
tailwind.config.ts carnet 2025-04-20 11:25:34 +02:00
tsconfig.json Initial commit 2025-04-17 11:39:15 +02:00
yarn.lock courrier refactor rebuild 2 2025-04-27 10:25:20 +02:00

Neah Email Application

A modern email client built with Next.js, featuring email composition, viewing, and management capabilities.

Email Processing Workflow

The application handles email processing through a centralized workflow:

  1. Email Fetching: Emails are fetched through the /api/courrier endpoints using user credentials stored in the database.

  2. Email Parsing: Raw email content is parsed using:

    • Server-side: parseEmail function from lib/server/email-parser.ts (which uses simpleParser from the mailparser library)
    • API route: /api/parse-email provides a REST interface to the parser
  3. HTML Sanitization: Email HTML content is sanitized and processed using:

    • sanitizeHtml function in lib/utils/email-formatter.ts (centralized implementation)
    • Text direction (RTL/LTR) is preserved automatically during sanitization
  4. Email Display: Sanitized content is rendered in the UI with proper styling and security measures

  5. Email Composition: The ComposeEmail component handles email creation, replying, and forwarding

    • Uses the centralized formatter functions to prepare content
    • Email is sent through the /api/courrier/send endpoint

Deprecated Functions

Several functions have been deprecated and removed in favor of centralized implementations:

  • Check the DEPRECATED_FUNCTIONS.md file for a complete list of deprecated functions and their replacements.

Project Structure

  • /app - Main application routes and API endpoints
  • /components - Reusable React components
  • /lib - Utility functions and services
    • /services - Domain-specific services, including email service
    • /server - Server-side utilities
    • /utils - Utility functions including the centralized email formatter

Dependencies

  • Next.js 15
  • React 18
  • ImapFlow for IMAP interactions
  • Mailparser for email parsing
  • Prisma for database interactions
  • Tailwind CSS for styling

Development

# Install dependencies
npm install

# Start the development server
npm run dev

# Build for production
npm run build

Email Formatting

Centralized Email Formatter

All email formatting is now handled by a centralized formatter in lib/utils/email-formatter.ts. This ensures consistent handling of:

  • Text direction (RTL/LTR)
  • HTML sanitization
  • Content formatting for forwards and replies
  • MIME encoding and decoding for email composition

Key Functions

  • formatForwardedEmail: Format emails for forwarding
  • formatReplyEmail: Format emails for replying
  • sanitizeHtml: Sanitize HTML while preserving direction attributes
  • formatEmailForReplyOrForward: Compatibility function for both
  • decodeComposeContent: Parse MIME content for email composition
  • encodeComposeContent: Create MIME-formatted content for sending emails

This centralized approach prevents formatting inconsistencies and direction problems when dealing with emails in different languages.