Deploying OpenTrashmail
Introduction
OpenTrashmail is an open-source disposable email service that allows users to create temporary email addresses on-the-fly without registration. Users can receive emails at any address on your configured domain, making it perfect for avoiding spam, testing email functionality, or maintaining privacy when signing up for services.
Unlike commercial disposable email services, self-hosting OpenTrashmail gives you complete control over your email infrastructure. You own the domain, control data retention, and ensure privacy since no third party sees your messages. The service works by catching all emails sent to any address at your domain and displaying them through a simple web interface.
Key highlights of OpenTrashmail:
- No Registration Required: Use any email address instantly without creating an account
- Catch-All Inbox: All emails to any address at your domain are captured
- Simple Web Interface: Clean, responsive UI for viewing received messages
- Attachment Support: View and download email attachments
- API Access: Programmatic access for automation and testing
- Automatic Cleanup: Configurable message retention and cleanup
- Multiple Domains: Support for multiple email domains
- Real-Time Updates: Messages appear instantly when received
- Self-Hosted Privacy: Complete control over your email data
- Lightweight: Minimal resource requirements for deployment
This guide walks through deploying OpenTrashmail on Klutch.sh using Docker, configuring DNS records, and setting up your disposable email service.
Why Deploy OpenTrashmail on Klutch.sh
Deploying OpenTrashmail on Klutch.sh provides several advantages:
Simplified Deployment: Klutch.sh automatically builds and deploys your disposable email service. Push your Dockerfile to GitHub and deploy with minimal configuration.
HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure access to your inbox web interface.
Persistent Storage: Attach persistent volumes to retain emails across container restarts. Configure retention periods to manage storage automatically.
GitHub Integration: Store your configuration in Git for version control. Update settings by pushing changes to your repository.
Custom Domains: Use your own domain for disposable addresses, making them appear more legitimate for services that block known temporary email domains.
Always-On Availability: Your email service runs 24/7, ready to receive messages whenever you need a temporary address.
Scalable Resources: Allocate resources based on expected email volume.
Prerequisites
Before deploying OpenTrashmail on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- Basic familiarity with Docker and containerization concepts
- A domain name you control for receiving emails
- Access to DNS configuration for your domain
Understanding OpenTrashmail Architecture
OpenTrashmail consists of several components:
SMTP Server: Receives incoming emails on port 25 (or configured port). Catches all mail regardless of the recipient address.
Web Interface: A lightweight frontend for viewing received messages, built with simple HTML/CSS/JavaScript.
API Backend: Provides programmatic access to mailboxes and messages for automation and integration.
File Storage: Emails are stored as files on disk, making backup and management straightforward.
Cleanup Process: Automatically removes old messages based on configured retention policies.
Preparing Your Repository
Create a GitHub repository containing your Dockerfile and configuration.
Repository Structure
opentrashmail/├── Dockerfile├── .dockerignore└── README.mdCreating the Dockerfile
Create a Dockerfile for OpenTrashmail:
FROM hascheksolutions/opentrashmail:latest
# Environment configurationENV DOMAINS="mail.example.com"ENV DATEFORMAT="D, d M Y H:i"ENV DISCARD_UNKNOWN="false"ENV DELETE_OLDER_THAN_DAYS="7"ENV ADMIN_PASSWORD=""
# Expose ports# SMTP port for receiving emailsEXPOSE 25
# Web interface portEXPOSE 80
# Use the default entrypointAdvanced Dockerfile Configuration
For more control over your deployment:
FROM hascheksolutions/opentrashmail:latest
# Domain configuration (comma-separated for multiple)ENV DOMAINS="mail.example.com,temp.example.org"
# Date display formatENV DATEFORMAT="D, d M Y H:i"
# Discard emails to unknown domainsENV DISCARD_UNKNOWN="true"
# Automatic cleanup after specified daysENV DELETE_OLDER_THAN_DAYS="7"
# Admin interface password (leave empty to disable)ENV ADMIN_PASSWORD=""
# URL path prefix (if behind reverse proxy)ENV URL_PREFIX=""
# Expose portsEXPOSE 25EXPOSE 80Environment Variables Reference
| Variable | Default | Description |
|---|---|---|
DOMAINS | - | Comma-separated list of email domains to accept |
DATEFORMAT | D, d M Y H:i | PHP date format for display |
DISCARD_UNKNOWN | false | Reject emails to unlisted domains |
DELETE_OLDER_THAN_DAYS | 0 | Auto-delete messages older than X days (0 = never) |
ADMIN_PASSWORD | - | Password for admin interface (empty = disabled) |
URL_PREFIX | - | URL prefix for reverse proxy setups |
DNS Configuration
Before deploying, configure DNS records for your domain:
Required DNS Records
- MX Record: Point your domain’s mail exchange to your server
Type: MXHost: mail (or @ for root domain)Value: your-app-name.klutch.shPriority: 10- A Record (if using subdomain): Point to your server
Type: AHost: mailValue: (Klutch.sh IP address)Optional DNS Records
For improved deliverability and spam prevention:
# SPF RecordType: TXTHost: @Value: v=spf1 a mx -all
# DMARC RecordType: TXTHost: _dmarcValue: v=DMARC1; p=noneDeploying OpenTrashmail on Klutch.sh
Follow these steps to deploy your disposable email service:
- Port 80: Web interface (HTTP)
- Port 25: SMTP for receiving emails
- Verify DNS records have propagated (may take up to 48 hours)
- Access the web interface at
https://your-app-name.klutch.sh - Send a test email to
test@your-email-domain.com - Check the web interface for the received message
Configure Your Domain
Before deployment, set up DNS records for your email domain. The MX record is essential for receiving emails.
Prepare Your Dockerfile
Update the DOMAINS environment variable with your configured domain(s):
ENV DOMAINS="mail.yourdomain.com"Push Your Repository to GitHub
Initialize and push your repository:
git initgit add Dockerfile .dockerignore README.mdgit commit -m "Initial OpenTrashmail configuration"git remote add origin https://github.com/yourusername/opentrashmail.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project named “opentrashmail” or “temp-mail”.
Create a New App
Within your project, create a new app. Connect your GitHub account and select the repository containing your Dockerfile.
Configure Network Traffic
Configure ports for your deployment:
Note: Port 25 may require special configuration. Contact Klutch.sh support if SMTP ports are restricted.
Set Environment Variables
Configure your service:
| Variable | Value |
|---|---|
DOMAINS | Your email domain(s) |
DELETE_OLDER_THAN_DAYS | 7 (or your preferred retention) |
DISCARD_UNKNOWN | true |
Attach Persistent Volumes
Add persistent storage for emails:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/var/www/opentrashmail/data | 10 GB | Email storage |
Deploy Your Application
Click Deploy to start the build process. Once complete, your disposable email service is ready.
Verify DNS and Test
After deployment:
Using OpenTrashmail
Accessing Mailboxes
Navigate to any email address on your domain:
https://your-app-name.klutch.sh/address/anything@mail.yourdomain.comOr use the main interface and enter an address to check.
Creating Temporary Addresses
Simply use any address at your domain:
signup@mail.yourdomain.comrandom123@mail.yourdomain.comnewsletter-test@mail.yourdomain.com
No registration or pre-creation required.
API Access
Access messages programmatically:
# List messages for an addresscurl https://your-app-name.klutch.sh/api/messages/user@mail.yourdomain.com
# Get a specific messagecurl https://your-app-name.klutch.sh/api/message/{message-id}Automation Use Cases
- Testing Email Flows: Verify signup confirmations and notifications
- CI/CD Pipelines: Test email sending in automated tests
- Webhook Testing: Receive email-based notifications
- Privacy Protection: Sign up for services without using your real email
Administration
Monitoring Email Volume
Track email usage:
- Check disk usage on persistent volume
- Review cleanup logs for deleted messages
- Monitor incoming email rate
Manual Cleanup
To manually remove old messages:
- Access the container console
- Navigate to the data directory
- Remove old message files
Blocking Spam
If receiving excessive spam:
- Enable
DISCARD_UNKNOWNto reject emails to unlisted domains - Consider implementing rate limiting
- Add sender blacklisting rules
Security Considerations
Public vs Private Deployment
- Public: Anyone can check any mailbox - suitable for testing services
- Private: Restrict access to specific users or networks
Data Privacy
- Emails are stored unencrypted on disk
- Configure automatic deletion to limit data exposure
- Consider network-level access restrictions for sensitive use
Preventing Abuse
- Monitor for abuse of your domain for spam
- Implement rate limiting if needed
- Consider requiring authentication for high-security environments
Troubleshooting Common Issues
Emails Not Arriving
Symptoms: Sent emails don’t appear in the interface.
Solutions:
- Verify MX records are correctly configured
- Check DNS propagation (use
dig MX yourdomain.com) - Verify SMTP port 25 is accessible
- Check container logs for connection attempts
- Ensure the sending domain isn’t blocking your server
Web Interface Not Loading
Symptoms: Cannot access the web interface.
Solutions:
- Verify the deployment is running
- Check HTTP port configuration
- Review container logs for errors
- Verify the URL is correct
Storage Full
Symptoms: New emails not being saved.
Solutions:
- Increase persistent volume size
- Enable automatic cleanup with
DELETE_OLDER_THAN_DAYS - Manually remove old messages
- Check for unusually large attachments
DNS Issues
Symptoms: Inconsistent email delivery.
Solutions:
- Wait for DNS propagation (up to 48 hours)
- Use multiple DNS checking tools to verify records
- Ensure MX priority is set correctly
- Check for conflicting DNS records
Additional Resources
- OpenTrashmail GitHub Repository
- OpenTrashmail Docker Hub
- MX Toolbox - DNS Verification
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
Conclusion
Deploying OpenTrashmail on Klutch.sh provides a private, self-hosted disposable email service. With your own domain, you avoid the blocked lists that affect public temporary email services while maintaining complete control over your data.
The combination of instant address creation, web-based access, and API support makes OpenTrashmail valuable for both personal privacy and development testing. Whether you need to sign up for services without revealing your real email or test email functionality in your applications, your self-hosted disposable email service is always ready.
Configure automatic cleanup to manage storage, and enjoy the freedom of unlimited temporary email addresses under your control.