A minimalist, self-hosted email client built with FastAPI, MongoDB, and Resend webhooks.
Features β’ Quick Start β’ Documentation β’ Contributing
Simple Email Client is a lightweight, self-hosted email management solution designed for individuals and small teams who want complete control over their email infrastructure. Built with modern technologies and a focus on simplicity, it provides a clean interface for receiving, viewing, and replying to emails through the Resend API.
- Complete Control: Self-hosted solution with no vendor lock-in
- Privacy First: Your emails stay on your infrastructure
- Easy Setup: 5-minute setup with an intuitive first-time wizard
- Clean Interface: Minimalist design focused on productivity
- Multi-User: Support for multiple users with role-based access
- API Driven: All settings configurable through web interface
- Email Management: Receive, view, reply, and delete emails
- Attachment Support: Store email attachments in Cloudflare R2
- Search & Filter: Find emails quickly (coming soon)
- Real-time Updates: Webhook-based email reception from Resend
- Simple Authentication: Username and password-based login
- Multi-User Support: Create and manage multiple user accounts
- Role-Based Access: Admin and regular user roles
- Secure Sessions: Session-based authentication with secure cookies
- Password Hashing: SHA256 password hashing
- First-Time Setup Wizard: Easy initial configuration
- Settings Panel: Configure all API keys through web interface
- User Management: Create, view, and delete users
- API Configuration: Manage Resend and Cloudflare R2 settings
- Modern Stack: FastAPI, MongoDB, Jinja2 templates
- Docker Ready: Complete Docker and Docker Compose support
- Minimalist UI: Clean design with no unnecessary elements
- REST API: Well-structured API endpoints
- Database Driven: All settings stored in MongoDB
Before you begin, ensure you have:
- Docker & Docker Compose (recommended) OR Python 3.9+
- MongoDB instance (local or remote)
- Resend Account (Sign up free)
- Cloudflare R2 (optional, for attachments)
-
Clone the repository
git clone https://github.com/yourusername/simple-email-client.git cd simple-email-client -
Create environment file
cp .env.example .env
-
Configure environment variables
Edit
.envfile:MONGODB_URI=mongodb://localhost:27017 DATABASE_NAME=email_client SECRET_KEY=your-random-secret-key-here
Generate a secure secret key:
python -c "import secrets; print(secrets.token_hex(32))" -
Start the application
docker-compose up -d
-
Access the application
Open your browser and navigate to:
http://localhost:8000 -
Complete the setup wizard
- Create your admin account (username, email, password)
- Navigate to Settings
- Add your Resend API key
- (Optional) Configure Cloudflare R2 credentials for attachments
That's it! Your email client is now ready to use.
If you prefer running without Docker:
-
Clone and navigate
git clone https://github.com/yourusername/simple-email-client.git cd simple-email-client -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
cp .env.example .env # Edit .env with your settings -
Run the application
python main.py
-
Access and setup
Navigate to
http://localhost:8000and complete the setup wizard.
Important: After completing the initial setup, you must configure Resend to forward incoming emails to your webhook endpoint.
- Set up inbound routing in your Resend Dashboard
- See the Resend Receiving Documentation for detailed instructions
- Go to Resend Webhooks
- Click "Add Webhook"
- Enter your webhook URL:
https://your-domain.com/webhook/email - Select the "email.received" event
- Click "Save"
Your webhook URL must be publicly accessible for Resend to send emails to your client. All emails sent to your configured Resend inbound email addresses will now be forwarded to your email client.
All API keys are configured through the web interface:
- Log in as an admin user
- Click "Settings" in the top navigation
- Fill in your API credentials:
- Resend API Key (required for sending replies)
- Cloudflare R2 credentials (optional, for attachments)
- Click "Save API Settings"
Only three environment variables are required:
| Variable | Description | Required | Example |
|---|---|---|---|
MONGODB_URI |
MongoDB connection string | Yes | mongodb://localhost:27017 |
DATABASE_NAME |
Database name | Yes | email_client |
SECRET_KEY |
Session secret key | Yes | Generate with Python secrets |
All other settings (Resend API, Cloudflare R2) are configured via the web interface.
When you first access the application, you'll see the setup wizard:
- Enter a username (will be used for login)
- Enter an email address
- Choose a strong password
- Confirm your password
- Click "Create Admin Account"
You'll be automatically logged in and redirected to Settings.
Admin users can create and manage other users:
- Go to Settings
- Scroll to "User Management" section
- Fill in the new user details:
- Username
- Password
- Admin privileges (checkbox)
- Click "Create User"
To delete a user, click the "Delete" button next to their name in the user table.
- Inbox: All received emails are displayed on the main page
- Unread: Unread emails are shown in bold
- Attachments: Emails with attachments show a badge with count
- Replied: Emails you've replied to show a "Replied" badge
- Click on an email to view it
- Scroll to the "Reply" section
- Type your reply message
- Click "Send Reply"
The email will be sent via your configured Resend API key.
simple-email-client/
βββ main.py # FastAPI application entry point
βββ database.py # MongoDB connection and collections
βββ auth.py # Authentication and user management
βββ email_service.py # Resend API integration
βββ r2_service.py # Cloudflare R2 integration
βββ templates/ # Jinja2 HTML templates
β βββ setup.html # Initial setup wizard
β βββ login.html # Login page
β βββ inbox.html # Email inbox
β βββ email_view.html # Single email view
β βββ settings.html # Admin settings panel
βββ Dockerfile # Docker container configuration
βββ docker-compose.yml # Docker Compose orchestration
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .dockerignore # Docker ignore rules
βββ .gitignore # Git ignore rules
βββ README.md # This file
βββ DEPLOYMENT.md # Detailed deployment guide
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/setup |
Initial setup page | No |
POST |
/setup |
Create first admin user | No |
GET |
/login |
Login page | No |
POST |
/login |
Authenticate user | No |
GET |
/logout |
Logout current user | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/ |
View inbox | Yes |
GET |
/email/{id} |
View specific email | Yes |
POST |
/email/{id}/reply |
Reply to email | Yes |
DELETE |
/email/{id} |
Delete email | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/settings |
Settings panel | Admin |
POST |
/settings/api |
Update API config | Admin |
POST |
/settings/users |
Create new user | Admin |
DELETE |
/settings/users/{username} |
Delete user | Admin |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/webhook/email |
Receive emails from Resend | No (webhook) |
For production environments, we recommend:
- Use HTTPS: Always use SSL/TLS in production
- Reverse Proxy: Use Nginx or Caddy as a reverse proxy
- Secure MongoDB: Enable authentication and use strong passwords
- Regular Backups: Schedule regular MongoDB backups
- Update Dependencies: Keep all dependencies up to date
See DEPLOYMENT.md for detailed production deployment instructions.
# Build and start
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downNginx:
server {
listen 80;
server_name mail.yourdomain.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}Caddy (with auto HTTPS):
mail.yourdomain.com {
reverse_proxy localhost:8000
}
- Strong Passwords: Enforce strong passwords for all users
- Secure Secret Key: Use a cryptographically secure random key
- HTTPS Only: Never run in production without HTTPS
- Regular Updates: Keep dependencies and Docker images updated
- MongoDB Security: Use authentication and restrict network access
- Backup Strategy: Implement regular automated backups
If you need to reset an admin password:
docker exec -it email-client python -c "
from database import users_collection
from auth import hash_password
users_collection.update_one(
{'username': 'admin'},
{'\$set': {'password': hash_password('newpassword')}}
)
print('Password reset successfully')
"Container won't start
# Check logs
docker-compose logs
# Common fixes:
# - Verify .env file exists and is configured
# - Check if port 8000 is available
# - Verify MongoDB connectionCan't connect to MongoDB
# Test connection
docker exec -it email-client python -c "from database import client; print(client.server_info())"Webhook not receiving emails
- Verify webhook URL is publicly accessible
- Check Resend webhook configuration
- Ensure webhook event is set to "email.received"
- Check application logs for errors
Emails not sending
- Verify Resend API key is configured in Settings
- Check Resend dashboard for quota limits
- Review application logs for error messages
For more troubleshooting tips, see DEPLOYMENT.md.
- Clone the repository
- Create virtual environment:
python -m venv venv - Activate:
source venv/bin/activate - Install dependencies:
pip install -r requirements.txt - Configure
.envfile - Run:
python main.py
# Coming soon
pytestThis project follows PEP 8 guidelines. Format your code with:
black .
flake8 .We welcome contributions from the community! Here's how you can help:
- Report Bugs: Open an issue with details about the bug
- Suggest Features: Share your ideas for new features
- Improve Documentation: Help make the docs better
- Submit Pull Requests: Fix bugs or add features
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Please ensure your PR:
- Follows existing code style
- Includes appropriate tests (when applicable)
- Updates documentation if needed
- Has a clear description of changes
- Documentation: Check DEPLOYMENT.md for detailed guides
- Issues: Open a GitHub issue
- Bug Reports: Use the issue tracker with the bug label
- Star this repository if you find it useful
- Share with others who might benefit
- Contribute to make it better
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Simple Email Client Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- FastAPI: Modern, fast web framework for Python
- MongoDB: Flexible document database
- Resend: Email API for developers
- Cloudflare R2: Object storage for attachments
Coming soon - screenshots of the application interface
Part of Projexa AI Open Source Initiative
Built with β€οΈ by the open-source community