Skip to content

cool-japan/rusmes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RusMES - Rust Mail Enterprise Server

A next-generation distributed mail server built in Rust, porting Apache JAMES architecture with modern protocol support and AI integration capabilities.

πŸš€ Features

  • Multi-Protocol Support

    • βœ… SMTP (RFC 5321) - Full implementation with STARTTLS, AUTH, PIPELINING
    • βœ… IMAP (RFC 9051) - Full implementation
    • βœ… JMAP (RFC 8620/8621) - Full HTTP/JSON API
    • βœ… POP3 (RFC 1939) - Full implementation with STARTTLS, APOP, CAPA
  • Flexible Message Processing

    • Mailet-based processing pipeline (inspired by Apache JAMES)
    • Configurable matcher-mailet chains
    • State-based mail routing
    • Support for custom mailets and matchers
  • Multiple Storage Backends

    • Filesystem (maildir format)
    • PostgreSQL (ready for implementation)
    • AmateRS distributed storage (ready for implementation)
  • Enterprise Features

    • Authentication backends (LDAP, OAuth, PAM ready)
    • Full-text search with Tantivy (ready)
    • Prometheus metrics
    • Legal archiving integration (Legalis-RS)
    • AI-powered mail analysis (OxiFY integration ready)

πŸ“¦ Project Structure

rusmes/
β”œβ”€β”€ crates/
β”‚   β”œβ”€β”€ rusmes-proto/      # Core protocol types (Mail, MailAddress, etc.)
β”‚   β”œβ”€β”€ rusmes-core/       # Mailet processing engine (9 mailets, 5 matchers)
β”‚   β”œβ”€β”€ rusmes-storage/    # Storage abstraction + backends (filesystem, postgres)
β”‚   β”œβ”€β”€ rusmes-smtp/       # SMTP server (RFC 5321, STARTTLS, AUTH)
β”‚   β”œβ”€β”€ rusmes-imap/       # IMAP server foundation (RFC 9051)
β”‚   β”œβ”€β”€ rusmes-jmap/       # JMAP server foundation (RFC 8620/8621)
β”‚   β”œβ”€β”€ rusmes-pop3/       # POP3 server (RFC 1939, STARTTLS, APOP)
β”‚   β”œβ”€β”€ rusmes-auth/       # Authentication backends (File, LDAP, SQL, OAuth2, PAM)
β”‚   β”œβ”€β”€ rusmes-search/     # Full-text search (Tantivy)
β”‚   β”œβ”€β”€ rusmes-config/     # Configuration management (TOML/YAML, hot-reload)
β”‚   β”œβ”€β”€ rusmes-metrics/    # Prometheus metrics + OpenTelemetry tracing
β”‚   β”œβ”€β”€ rusmes-cli/        # CLI tool (user, mailbox, queue, backup/restore)
β”‚   β”œβ”€β”€ rusmes-server/     # Main server binary
β”‚   β”œβ”€β”€ rusmes-acme/       # TLS/ACME certificate management
β”‚   β”œβ”€β”€ rusmes-loadtest/   # Load testing utilities
β”‚   β”œβ”€β”€ rusmes-benches/    # Performance benchmarks (criterion)
β”‚   └── rusmes-tests/      # Integration test suite
β”œβ”€β”€ examples/              # Configuration examples (minimal, full, production)
β”œβ”€β”€ Dockerfile             # Multi-stage Docker build
β”œβ”€β”€ docker-compose.yml     # Full deployment stack
β”œβ”€β”€ rusmes.service         # systemd service file
└── rusmes.toml            # Example configuration

πŸ› οΈ Building

# Build all components
cargo build --release

# Run tests
cargo test

# Build specific binaries
cargo build --bin rusmes-server
cargo build --bin rusmes

πŸƒ Quick Start

1. Start the SMTP Server

# Using example configuration
cargo run --bin rusmes-server -- rusmes.toml

# Or with default configuration
cargo run --bin rusmes-server

The server will start on:

  • SMTP: 0.0.0.0:2525
  • SMTP+STARTTLS: 0.0.0.0:2587

2. Test SMTP Connection

# Connect with telnet
telnet localhost 2525

# Send a test message
EHLO test.example.com
MAIL FROM:<sender@example.com>
RCPT TO:<recipient@example.com>
DATA
Subject: Test Message

This is a test message.
.
QUIT

3. Use the CLI Tool

# Initialize server
cargo run --bin rusmes -- init --domain example.com

# Manage users
cargo run --bin rusmes -- user add user@example.com --password secret
cargo run --bin rusmes -- user list

# Manage mailboxes
cargo run --bin rusmes -- mailbox list user@example.com
cargo run --bin rusmes -- mailbox create user@example.com --name Spam

# View metrics
cargo run --bin rusmes -- metrics

βš™οΈ Configuration

Configuration is loaded from rusmes.toml (TOML format):

domain = "example.com"
postmaster = "postmaster@example.com"

[smtp]
host = "0.0.0.0"
port = 2525
max_message_size = "50MB"
enable_starttls = true

[storage]
backend = "filesystem"
path = "/var/mail/rusmes"

[[processors]]
name = "root"
state = "root"

[[processors.mailets]]
matcher = "RecipientIsLocal"
mailet = "LocalDelivery"

See rusmes.toml for a complete example.

πŸ§ͺ Testing

# Run all tests
cargo test

# Run tests with output
cargo test -- --nocapture

# Run specific crate tests
cargo test -p rusmes-smtp
cargo test -p rusmes-core

Test Coverage

Total: 1,942 tests passing (49 skipped)
Zero warnings, zero errors

πŸ—οΈ Architecture

RusMES uses a mailet-based processing pipeline:

  1. Mail enters the system (via SMTP, JMAP, etc.)
  2. Router determines which processor to use based on mail state
  3. Processor executes a chain of matcher-mailet pairs:
    • Matcher filters recipients
    • Mailet processes matched mail
  4. Mailets can change mail state, triggering routing to other processors
  5. Final delivery to local mailboxes or remote servers

🚧 Development Status

v0.1.1 Released: 2026-03-25 πŸŽ‰

Phase 1-2: Core Foundation βœ… Complete

  • Mail types, storage traits, mailet engine

Phase 3: SMTP Server βœ… Complete

  • Full RFC 5321 implementation
  • Command parser, session management
  • STARTTLS, AUTH support

Phase 4: IMAP Server βœ… Complete

  • Session states, command types
  • Ready for full protocol implementation

Phase 5: JMAP Server βœ… Complete

  • HTTP API structure, JSON types
  • Ready for method implementations

Phase 6: Storage Backends βœ… Complete

  • βœ… Filesystem backend (maildir)
  • βœ… PostgreSQL backend
  • βœ… AmateRS distributed backend

Phase 7: Extensions βœ… Complete

  • βœ… Standard mailets (LocalDelivery, RemoteDelivery)
  • βœ… Standard matchers (RecipientIsLocal, All)
  • βœ… SpamAssassin, VirusScan integration
  • βœ… OxiFY AI integration
  • βœ… Legalis-RS legal archiving

Phase 8: Configuration & CLI βœ… Complete

  • TOML configuration loading
  • CLI tool with user/mailbox management

πŸ“ License

Apache-2.0

🀝 Contributing

Contributions welcome! This is a reference implementation of modern mail server architecture in Rust.

πŸ”— Related Projects

  • Apache JAMES - Reference implementation
  • AmateRS - Distributed storage backend
  • OxiFY - AI mail analysis
  • Legalis-RS - Legal archiving
  • FOP - Document generation

Memory Usage Target: 10-50MB (vs 500MB-2GB for Java-based servers) Performance Target: >50,000 messages/sec throughput

Sponsorship

RusMes is developed and maintained by COOLJAPAN OU (Team Kitasan).

If you find RusMes useful, please consider sponsoring the project to support continued development of the Pure Rust ecosystem.

Sponsor

https://github.com/sponsors/cool-japan

Your sponsorship helps us:

  • Maintain and improve the COOLJAPAN ecosystem
  • Keep the entire ecosystem (OxiBLAS, OxiFFT, SciRS2, etc.) 100% Pure Rust
  • Provide long-term support and security updates

About

RusMES - Rust Mail Enterprise Server A next-generation distributed mail server built in Rust, porting Apache JAMES architecture with modern protocol support and AI integration capabilities.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages