Skip to content

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.md

Creating the Dockerfile

Create a Dockerfile for OpenTrashmail:

FROM hascheksolutions/opentrashmail:latest
# Environment configuration
ENV 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 emails
EXPOSE 25
# Web interface port
EXPOSE 80
# Use the default entrypoint

Advanced 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 format
ENV DATEFORMAT="D, d M Y H:i"
# Discard emails to unknown domains
ENV DISCARD_UNKNOWN="true"
# Automatic cleanup after specified days
ENV 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 ports
EXPOSE 25
EXPOSE 80

Environment Variables Reference

VariableDefaultDescription
DOMAINS-Comma-separated list of email domains to accept
DATEFORMATD, d M Y H:iPHP date format for display
DISCARD_UNKNOWNfalseReject emails to unlisted domains
DELETE_OLDER_THAN_DAYS0Auto-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

  1. MX Record: Point your domain’s mail exchange to your server
Type: MX
Host: mail (or @ for root domain)
Value: your-app-name.klutch.sh
Priority: 10
  1. A Record (if using subdomain): Point to your server
Type: A
Host: mail
Value: (Klutch.sh IP address)

Optional DNS Records

For improved deliverability and spam prevention:

# SPF Record
Type: TXT
Host: @
Value: v=spf1 a mx -all
# DMARC Record
Type: TXT
Host: _dmarc
Value: v=DMARC1; p=none

Deploying OpenTrashmail on Klutch.sh

Follow these steps to deploy your disposable email service:

    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:

    Terminal window
    git init
    git add Dockerfile .dockerignore README.md
    git commit -m "Initial OpenTrashmail configuration"
    git remote add origin https://github.com/yourusername/opentrashmail.git
    git push -u origin main

    Create 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:

    • Port 80: Web interface (HTTP)
    • Port 25: SMTP for receiving emails

    Note: Port 25 may require special configuration. Contact Klutch.sh support if SMTP ports are restricted.

    Set Environment Variables

    Configure your service:

    VariableValue
    DOMAINSYour email domain(s)
    DELETE_OLDER_THAN_DAYS7 (or your preferred retention)
    DISCARD_UNKNOWNtrue

    Attach Persistent Volumes

    Add persistent storage for emails:

    Mount PathRecommended SizePurpose
    /var/www/opentrashmail/data10 GBEmail 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:

    1. Verify DNS records have propagated (may take up to 48 hours)
    2. Access the web interface at https://your-app-name.klutch.sh
    3. Send a test email to test@your-email-domain.com
    4. Check the web interface for the received message

Using OpenTrashmail

Accessing Mailboxes

Navigate to any email address on your domain:

https://your-app-name.klutch.sh/address/anything@mail.yourdomain.com

Or use the main interface and enter an address to check.

Creating Temporary Addresses

Simply use any address at your domain:

  • signup@mail.yourdomain.com
  • random123@mail.yourdomain.com
  • newsletter-test@mail.yourdomain.com

No registration or pre-creation required.

API Access

Access messages programmatically:

Terminal window
# List messages for an address
curl https://your-app-name.klutch.sh/api/messages/user@mail.yourdomain.com
# Get a specific message
curl 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:

  1. Access the container console
  2. Navigate to the data directory
  3. Remove old message files

Blocking Spam

If receiving excessive spam:

  • Enable DISCARD_UNKNOWN to 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

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.