78 lines
2.6 KiB
Markdown
78 lines
2.6 KiB
Markdown
# 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: `simpleParser` from `mailparser` library via `/api/parse-email` API route
|
|
- Client-side: `decodeEmail` function in `lib/mail-parser-wrapper.ts`
|
|
|
|
3. **HTML Sanitization**: Email HTML content is sanitized and processed using:
|
|
- `cleanHtml` function in `lib/mail-parser-wrapper.ts` (centralized implementation)
|
|
- CSS styles are optionally preserved and scoped to prevent leakage
|
|
|
|
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
|
|
- `initializeForwardedEmail` function prepares forwarded email content
|
|
- Email is sent through the `/api/courrier/send` endpoint
|
|
|
|
## Deprecated Functions
|
|
|
|
Several functions have been marked as deprecated 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
|
|
|
|
## Dependencies
|
|
|
|
- Next.js 15
|
|
- React 18
|
|
- ImapFlow for IMAP interactions
|
|
- Mailparser for email parsing
|
|
- Prisma for database interactions
|
|
- Tailwind CSS for styling
|
|
|
|
## Development
|
|
|
|
```bash
|
|
# 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
|
|
|
|
### Key Functions
|
|
|
|
- `formatForwardedEmail`: Format emails for forwarding
|
|
- `formatReplyEmail`: Format emails for replying
|
|
- `cleanHtmlContent`: Sanitize HTML while preserving direction attributes
|
|
- `formatEmailForReplyOrForward`: Compatibility function for both
|
|
|
|
This centralized approach prevents formatting inconsistencies and direction problems when dealing with emails in different languages. |