A robust .NET 8 web application for archiving emails from IMAP servers into a PostgreSQL database with a modern web interface for searching and viewing archived emails.
- π§ IMAP Email Archiving: Connect to any IMAP email server and archive emails locally
- π Advanced Search: Search through archived emails by sender, subject, date, and content
- π Attachment Support: Download and store email attachments with full metadata
- β° Automated Archiving: Schedule automatic email archiving using Quartz.NET
- π Web Interface: Modern, responsive web interface for managing and viewing emails
- π³ Containerized: Ready-to-deploy Docker containers and Kubernetes manifests
- π Progress Tracking: Real-time progress monitoring for archiving operations
- π Secure: Encrypted storage of IMAP credentials and secure authentication
The application follows a clean architecture pattern with the following projects:
- NetMailArchiver.Web: ASP.NET Core web application with Razor Pages
- NetMailArchiver.Services: Business logic and IMAP service implementations
- NetMailArchiver.DataAccess: Entity Framework Core data access layer
- NetMailArchiver.Models: Domain models and entities
- .NET 8 SDK
- PostgreSQL 12+
- Docker (optional, for containerized deployment)
- Kubernetes cluster (optional, for Kubernetes deployment)
git clone https://github.com/Knabbermann/NetMailArchiver.git
cd NetMailArchiverUpdate the connection string in NetMailArchiver.Web/Program.cs:
options.UseNpgsql("Host=your-postgres-host;Database=NetMailArchiver;Username=your-username;Password=your-password")cd NetMailArchiver.Web
dotnet ef database updatedotnet restore
dotnet build
dotnet run --project NetMailArchiver.WebThe application will be available at https://localhost:5001 or http://localhost:5000.
- Navigate to the web interface
- Add your IMAP server configuration:
- Host: Your IMAP server hostname
- Port: IMAP port (usually 993 for SSL, 143 for STARTTLS)
- Username: Your email username
- Password: Your email password
- Use SSL: Enable for secure connections
- Auto Archive: Enable automatic archiving
- Archive Interval: Set archiving frequency
You can override configuration using environment variables:
ASPNETCORE_ENVIRONMENT: Set toDevelopmentorProductionDATABASE_CONNECTION_STRING: PostgreSQL connection string
docker build -t netmailarchiver:latest -f NetMailArchiver.Web/Dockerfile .Create a docker-compose.yml:
version: '3.8'
services:
netmailarchiver:
image: netmailarchiver:latest
ports:
- "8080:8080"
environment:
- DATABASE_CONNECTION_STRING=Host=postgres;Database=NetMailArchiver;Username=postgres;Password=yourpassword
depends_on:
- postgres
postgres:
image: postgres:15
environment:
- POSTGRES_DB=NetMailArchiver
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=yourpassword
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
postgres_data:Run with:
docker-compose up -dDeploy to Kubernetes using the provided manifests:
kubectl apply -f k8s/The deployment includes:
- Application deployment with configurable replicas
- Service for load balancing
- Persistent volume claims for database storage
- Open the web interface
- Click "Add IMAP Account" (if no accounts exist)
- Fill in your IMAP server details
- Test the connection
- Save the configuration
Manual Archiving:
- Click "Archive New Mails" to archive only new emails
- Click "Archive All Mails" to archive all emails from the server
Automatic Archiving:
- Enable "Auto Archive" in the IMAP configuration
- Set the desired archive interval
- The system will automatically archive new emails based on the schedule
- Navigate to the "Archive" section
- Use the search box to find specific emails
- Click "Open" to view email content in a new window
- Click "Download Attachments" to download email attachments
The application provides several API endpoints for integration:
GET /Archive/Index?handler=GetEmails: Retrieve archived emails (with pagination)GET /Archive/Index?handler=OpenEmail: Open a specific emailGET /Archive/Index?handler=DownloadAttachment: Download email attachmentsGET /?handler=ArchiveProgress: Get archiving progress status
- Install .NET 8 SDK
- Install PostgreSQL locally
- Clone the repository
- Restore packages:
dotnet restore - Update database:
dotnet ef database update --project NetMailArchiver.Web - Run the application:
dotnet run --project NetMailArchiver.Web
NetMailArchiver/
βββ NetMailArchiver.Web/ # Web application (Razor Pages)
βββ NetMailArchiver.Services/ # Business logic and services
βββ NetMailArchiver.DataAccess/ # Entity Framework data access
βββ NetMailArchiver.Models/ # Domain models
βββ k8s/ # Kubernetes manifests
βββ README.md
- ASP.NET Core 8: Web framework
- Entity Framework Core: ORM for database access
- MailKit: IMAP client library
- Quartz.NET: Job scheduling
- PostgreSQL: Database
- Bootstrap: UI framework
- jQuery: Frontend interactions
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow existing code style and conventions
- Add appropriate tests for new functionality
- Update documentation as needed
- Ensure all tests pass before submitting PR
This project is open source. Please check the repository for license details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information about your problem
- Provide logs and configuration details when reporting bugs
Future enhancements may include:
- Support for additional email protocols (POP3, Exchange)
- Email backup and export functionality
- Advanced filtering and tagging
- Multi-user support with authentication
- Email analytics and reporting
- Mobile-responsive improvements
Note: This application handles sensitive email data. Ensure proper security measures are in place when deploying to production environments.