Skip to main content

A simple SMTP server for receiving emails with REST API access

Project description

AEmail - Simple Email Receive Server

Python Poetry License

A simple SMTP server for receiving emails with REST API access. Perfect for testing, development, and automation scenarios where you need to receive emails programmatically.

Features

  • ๐Ÿš€ Simple SMTP Server: Receives emails on any address with your domain
  • ๐ŸŒ REST API: Easy access to received emails via HTTP endpoints
  • ๐Ÿ’พ Flexible Storage: In-memory or SQLite database storage
  • ๐Ÿ”ง Easy Configuration: Environment variables and config file support
  • ๐Ÿ“ฆ Poetry Package: Professional Python packaging with wheel support
  • ๐Ÿ–ฅ๏ธ Command Line Tool: Simple CLI for starting the server
  • ๐ŸŽจ Web Interface: Modern web UI for browsing emails
  • ๐Ÿ” Search Functionality: Find emails by sender or recipient

Use Cases

  • Batch Registration: Register multiple accounts and receive verification emails
  • Email Testing: Test email functionality in development environments
  • Automation: Programmatically access received emails for processing
  • Development: Mock email server for local development

Quick Start

Installation

# Install with pip
pip install aemail

# Or install with Poetry
poetry add aemail

Basic Usage

# Start the server with default settings
aemail-server

# Start with custom ports
aemail-server --smtp-port 2525 --rest-port 8080

# Start with persistent database
aemail-server --db-file emails.db

# Start with custom config
aemail-server --config my-config.ini

DNS Configuration

To receive emails for your domain, configure DNS records:

A Record

Point your mail subdomain to your server IP:

A    mx    YOUR.SERVER.IP.ADDRESS

MX Record

Configure MX record to route emails to your server:

MX   *    mx.yourdomain.com

The * wildcard means ALL subdomains will be routed to your server. Examples: test@yourdomain.com, anything@sub.yourdomain.com This gives you unlimited email addresses!

API Endpoints

The server provides a REST API for accessing received emails:

GET /all

Get all stored messages (last 100)

curl http://localhost:14000/all

GET /from/{email}

Get messages from a specific sender

curl http://localhost:14000/from/sender@example.com

GET /to/{email}

Get messages to a specific recipient

curl http://localhost:14000/to/recipient@example.com

GET /health

Health check endpoint

curl http://localhost:14000/health

Response Format

[
  {
    "from": "sender@example.com",
    "to": ["recipient@example.com"],
    "to0": "recipient@example.com",
    "subject": "Test Email",
    "content": "Email content here...",
    "time": "2024-01-01T12:00:00"
  }
]

Configuration

Config File (cfg.ini)

[smtpd]
host = ::          # Listen on all interfaces (IPv4 and IPv6)
port = 25

[rest]
port = 14000

Environment Variables

Override config file settings with environment variables:

  • SMTP_HOST - SMTP server host (default: :: - all interfaces)
  • SMTP_PORT - SMTP server port (default: 25)
  • REST_PORT - REST API port (default: 14000)

Command Line Options

aemail-server --help

Options:
  --config, -c          Path to configuration file
  --smtp-host          SMTP server host
  --smtp-port          SMTP server port
  --rest-port          REST API port
  --db-file            SQLite database file path
  --verbose, -v        Enable verbose logging
  --version            Show version

Development

From Source

# Clone the repository
git clone https://github.com/lycying/aemail.git
cd aemail

# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -

# Install dependencies
poetry install

# Run the server
poetry run aemail-server

# Run tests
poetry run pytest

# Build wheel package
poetry build

Project Structure

aemail/
โ”œโ”€โ”€ crazy_email_recv_srv/     # Main package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py               # Command line interface
โ”‚   โ”œโ”€โ”€ config.py            # Configuration management
โ”‚   โ”œโ”€โ”€ data.py              # Data access layer
โ”‚   โ”œโ”€โ”€ email_handler.py     # SMTP email processing
โ”‚   โ”œโ”€โ”€ server.py            # Main server
โ”‚   โ”œโ”€โ”€ utils.py             # Utility functions
โ”‚   โ””โ”€โ”€ web_api.py           # REST API
โ”œโ”€โ”€ tests/                   # Test suite
โ”œโ”€โ”€ static/                  # Web interface files
โ”œโ”€โ”€ pyproject.toml          # Poetry configuration
โ””โ”€โ”€ README.md

Testing

Send a test email to any address at your domain:

# Example: Send email to test@yourdomain.com
# Then query the API:
curl http://localhost:14000/to/test@yourdomain.com

Or use the web interface at: http://localhost:14000

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Support


Note: This tool is for testing and development purposes. Use responsibly and in compliance with applicable laws and regulations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aemail-0.2.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aemail-0.2.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file aemail-0.2.1.tar.gz.

File metadata

  • Download URL: aemail-0.2.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Windows/11

File hashes

Hashes for aemail-0.2.1.tar.gz
Algorithm Hash digest
SHA256 220f6fe5f622efbe6824f50b012e073b39c51eb112d440006ce72b2165f8e230
MD5 d0b09acde87d43decda3de6a59e8d965
BLAKE2b-256 d1d0e204492dcb9c70ba00fc653d21db2c7b2542a5b954b117d2ed2bd99f5baa

See more details on using hashes here.

File details

Details for the file aemail-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: aemail-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Windows/11

File hashes

Hashes for aemail-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 598d372591e08344917a6f4b62117f7dfde2d05e73ffd5aa2011daac903b5fbb
MD5 44456d0d95e2ea7465a765cd228dbcdb
BLAKE2b-256 53cee70328fb4cbe382c14257d03aac161caaaf15c79958412e1e5d33075baee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page