Website β’ Documentation β’ API Reference β’ Support
A production-ready Rust SMTP server that accepts emails and forwards them to the MailPace API with enterprise-grade reliability and performance.
- Key Features
- Quick Start
- Configuration
- Authentication
- SMTP Client Configuration
- Usage
- MailPace Features
- Attachment Support
- HTML Compression
- Error Handling
- Development
- Testing
- License
- π High-Performance SMTP Server - Built with Rust for maximum throughput and reliability
- π Enterprise Authentication - Full SMTP authentication with MailPace API token integration
- π Smart Attachment Handling - Automatic MIME parsing with configurable size limits
- ποΈ HTML Compression - Intelligent compression optimized for email clients
- π TLS/STARTTLS Support - Secure email transmission with modern encryption
- π Advanced Monitoring - Comprehensive logging and error reporting
- π·οΈ MailPace Integration - Native support for tags, list-unsubscribe, and custom headers
- β‘ Zero-Downtime Deployment - Docker-ready with health checks and graceful shutdown
- Rust 1.88+
- MailPace Account with API token
-
Clone the repository:
git clone https://github.com/mailpace/vibe-smtp.git cd vibe-smtp
-
Build and run:
cargo run
-
Test the connection:
python3 test_smtp.py
For comprehensive Docker setup with multi-port support, see DOCKER.md.
# Clone and build
git clone https://github.com/mailpace/vibe-smtp.git
cd vibe-smtp
# Run with all SMTP ports using the helper script
./docker-run.sh multi-port --token your_api_token
# Or use Docker Compose
docker-compose up -d
The Docker setup supports industry-standard SMTP ports:
Port | Protocol | Description | TLS Support |
---|---|---|---|
25 | SMTP | Standard mail transfer | STARTTLS optional |
587 | Submission | Message submission | STARTTLS optional |
2525 | Alternative | Development/testing | STARTTLS optional |
465 | SMTPS | SMTP over SSL | Implicit TLS (no STARTTLS) |
Option 1: Helper Script (Recommended)
# Multi-port mode with all SMTP ports
./docker-run.sh multi-port --token your_api_token
# Single-port mode (port 2525 only)
./docker-run.sh single-port --token your_api_token
# Development mode with debug logging
./docker-run.sh multi-port --dev --token your_api_token
Option 2: Docker Compose
# Copy environment file and edit with your API token
cp .env.example .env
# Edit .env and set MAILPACE_API_TOKEN=your_token
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f vibe-gateway
Option 3: Direct Docker Commands
# Build the image
docker build -t vibe-gateway .
# Run multi-port mode
docker run -p 25:25 -p 587:587 -p 2525:2525 -p 465:465 \
-e MAILPACE_API_TOKEN=your_token \
vibe-gateway --docker-multi-port
# Run single-port mode
docker run -p 2525:2525 \
-e MAILPACE_API_TOKEN=your_token \
vibe-gateway --listen 0.0.0.0:2525 --enable-tls
The Docker image includes test certificates for development. For production:
Option 1: Mount your own certificates
docker run -p 25:25 -p 587:587 -p 2525:2525 -p 465:465 \
-v /path/to/your/cert.pem:/app/test_cert.pem:ro \
-v /path/to/your/key.pem:/app/test_key.pem:ro \
-e MAILPACE_API_TOKEN=your_token \
vibe-gateway --docker-multi-port
Option 2: Use Docker Compose with custom certificates
# docker-compose.override.yml
services:
vibe-gateway:
volumes:
- ./your_cert.pem:/app/test_cert.pem:ro
- ./your_key.pem:/app/test_key.pem:ro
- Security: Use proper TLS certificates in production
- Firewall: Only expose necessary ports (typically 587 and 465)
- Monitoring: Use the built-in health check endpoint
- Backup: Ensure your MailPace API token is securely stored
- Scaling: Run multiple containers behind a load balancer if needed
The Docker image includes health checks that verify SMTP connectivity:
# Check container health
docker inspect --format='{{.State.Health.Status}}' container_name
# Manual health check
docker exec container_name timeout 5 bash -c '</dev/tcp/localhost/2525'
The server supports the following configuration options:
--listen
or-l
: SMTP server listen address (default:127.0.0.1:2525
)--mailpace-endpoint
: MailPace API endpoint (default:https://app.mailpace.com/api/v1/send
)--default-mailpace-token
: Default MailPace API token (optional, can also be set viaMAILPACE_API_TOKEN
environment variable)--enable-tls
: Enable TLS/STARTTLS support--enable-attachments
: Enable attachment parsing and forwarding--max-attachment-size
: Maximum size per attachment in bytes (default: 10MB)--max-attachments
: Maximum number of attachments per email (default: 10)--enable-html-compression
: Enable HTML compression for email bodies--debug
or-d
: Enable debug logging
Vibe Gateway follows the MailPace SMTP authentication model for seamless integration:
Users authenticate using their MailPace API token as both username and password:
- Username: Your MailPace API token
- Password: Your MailPace API token (same as username)
Configure a default token for clients that can't provide authentication:
- Set via
--default-mailpace-token
flag - Or use
MAILPACE_API_TOKEN
environment variable
API tokens are available in your MailPace Dashboard under: Domain Settings β API Tokens
π‘ Note: Each domain has a unique API token for security and isolation.
-
Option 1: Users authenticate with their tokens (recommended):
cargo run
-
Option 2: Use a default token:
export MAILPACE_API_TOKEN=your_default_token_here cargo run
-
Test with the included Python script:
python3 test_smtp.py
Configure your email client or application with these settings:
Setting | Value | Notes |
---|---|---|
SMTP Server | localhost |
Or your server's IP address |
SMTP Port | 25 , 587 , 2525 , or 465 |
See port details below |
Encryption | Varies by port | See TLS configuration below |
Authentication | PLAIN or LOGIN | Standard SMTP AUTH methods |
Username | Your MailPace API token | Get from MailPace Dashboard |
Password | Your MailPace API token | Same as username |
Port | Purpose | TLS Mode | Encryption | Typical Use |
---|---|---|---|---|
25 | Standard SMTP | STARTTLS optional | None/STARTTLS | Mail transfer agents |
587 | Message Submission | STARTTLS optional | None/STARTTLS | Email clients (recommended) |
2525 | Alternative SMTP | STARTTLS optional | None/STARTTLS | Development/testing |
465 | SMTP over SSL | Implicit TLS | SSL/TLS required | Legacy email clients |
π‘ Recommendation: Use port 587 for email clients as it's the modern standard for message submission.
Postfix Configuration
# /etc/postfix/main.cf
# Use port 587 for message submission (recommended)
relayhost = [localhost]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
# /etc/postfix/sasl_passwd
[localhost]:587 your_api_token:your_api_token
# Alternative: Use port 25 for standard SMTP
# relayhost = [localhost]:25
Nodemailer (Node.js)
// Recommended: Port 587 with STARTTLS
const transporter = nodemailer.createTransporter({
host: 'localhost',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'your_api_token',
pass: 'your_api_token'
}
});
// Alternative: Port 465 with implicit TLS
const secureTransporter = nodemailer.createTransporter({
host: 'localhost',
port: 465,
secure: true, // implicit TLS
auth: {
user: 'your_api_token',
pass: 'your_api_token'
}
});
-
Primary usage (users provide their own API tokens):
cargo run
-
With default token fallback (optional):
export MAILPACE_API_TOKEN=your_default_token_here cargo run
-
With custom settings:
cargo run -- --listen 0.0.0.0:587 --debug
When a user connects via SMTP:
- They authenticate using their MailPace API token as both username and password
- The server extracts this token from the SMTP AUTH command
- The server uses this token to authenticate with the MailPace API
- If no token is provided via SMTP AUTH, the server falls back to a default token (if configured)
The server supports the following MailPace-specific features:
Add tags to emails by including the X-MailPace-Tags
header:
X-MailPace-Tags: tag1, tag2, tag3
Add unsubscribe links by including the X-List-Unsubscribe
header:
X-List-Unsubscribe: <http://example.com/unsubscribe>, <mailto:[email protected]>
Standard MIME attachments are automatically converted to MailPace format with base64 encoding.
The server supports email attachments when enabled with the --enable-attachments
flag:
cargo run -- --enable-attachments
--enable-attachments
: Enable attachment parsing and forwarding--max-attachment-size
: Maximum size per attachment in bytes (default: 10MB)--max-attachments
: Maximum number of attachments per email (default: 10)
When attachment support is enabled, the server:
- Parses MIME multipart messages
- Extracts attachments with their filenames and content types
- Converts attachments to base64 format for MailPace API
- Validates attachment sizes and counts against configured limits
- Logs attachment processing for debugging
# Enable attachments with custom limits
cargo run -- --enable-attachments --max-attachment-size 5242880 --max-attachments 5
# Test with the attachment test script
python3 test_attachment.py
The server supports HTML compression for email bodies to reduce bandwidth and improve delivery performance:
cargo run -- --enable-html-compression
- Automatic Detection: Only compresses content that appears to be HTML
- Safe Compression: Preserves email client compatibility by keeping essential tags
- Comment Removal: Strips HTML comments to reduce size
- Whitespace Optimization: Removes unnecessary whitespace while preserving content
- CSS/JS Minification: Minifies inline CSS and JavaScript
- Fallback Handling: Uses original content if compression fails
--enable-html-compression
: Enable HTML compression for email bodies
When HTML compression is enabled, the server:
- Detects HTML content using heuristics (looks for common HTML tags)
- Applies safe compression settings optimized for email clients
- Removes comments and unnecessary whitespace
- Minifies inline CSS and JavaScript
- Logs compression statistics for monitoring
- Falls back to original content if compression fails
# Enable both attachments and HTML compression
cargo run -- --enable-attachments --enable-html-compression
# Or with TLS support
cargo run -- --enable-tls --enable-html-compression
The included test_attachment.py
script demonstrates sending an email with an attachment:
python3 test_attachment.py
This script creates a test email with:
- Plain text body
- A sample text file attachment
- Proper MIME encoding
The server provides detailed error messages back to SMTP clients:
- Authentication errors
- API token validation
- MailPace API errors
- Email parsing errors
- Rust 1.88+ with Cargo
- Git
- Docker (optional)
-
Clone and setup:
git clone https://github.com/mailpace/vibe-smtp.git cd vibe-smtp
-
Build and run:
cargo build cargo run
-
Development with auto-reload:
cargo install cargo-watch cargo watch -x run
-
Debug mode with detailed logging:
cargo run -- --debug
src/
βββ main.rs # Application entry point
βββ lib.rs # Library exports
βββ cli.rs # Command-line interface
βββ smtp.rs # SMTP server implementation
βββ mailpace.rs # MailPace API integration
βββ connection.rs # Connection handling
βββ compression.rs # HTML compression
βββ mime.rs # MIME parsing
βββ tls.rs # TLS/encryption support
# Format code
cargo fmt
# Lint code
cargo clippy
# Security audit
cargo audit
# Documentation
cargo doc --open
Crate | Purpose | Version |
---|---|---|
tokio |
Async runtime and networking | Latest |
reqwest |
HTTP client for MailPace API | Latest |
mail-parser |
RFC-compliant email parsing | Latest |
serde |
JSON serialization framework | Latest |
base64 |
Attachment encoding | Latest |
tracing |
Structured logging | Latest |
clap |
Command-line argument parsing | Latest |
We welcome contributions! Please see our Contributing Guide for details.
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
Vibe Gateway is proudly developed by MailPace - the developer-friendly email delivery service.
- π 99.9% Uptime SLA - Enterprise-grade reliability
- π° Transparent Pricing - No hidden fees or overages
- π‘οΈ Privacy-First - GDPR compliant with EU data residency
- π Real-time Analytics - Advanced delivery insights
- π€ Developer-Friendly - Comprehensive APIs and documentation
π Website β’ π Documentation β’ π¬ Discord β’ π¦ Twitter β’ π§ Support
Built with β€οΈ by the MailPace team
This project includes a comprehensive test suite to ensure reliability and performance:
- Integration Tests: End-to-end SMTP functionality with mock MailPace API
- Unit Tests: Individual component testing with 95%+ coverage
- Performance Tests: Load testing and throughput benchmarking
- Security Tests: Authentication and input validation
- CI/CD Pipeline: Automated testing on every commit
# Run all tests with coverage
./test.sh
# Run specific test suites
./test.sh integration # Integration tests only
./test.sh unit # Unit tests only
./test.sh performance # Performance tests only
./test.sh coverage # Generate coverage report
# All tests
cargo test
# Integration tests with mock MailPace API
cargo test --test integration_tests
# Unit tests for individual components
cargo test --test mailpace_tests
# Performance and load tests
cargo test --test performance_tests --release
- SMTP Protocol: Command handling, authentication, data transfer
- MailPace Integration: API calls, error handling, payload formatting
- Email Processing: Attachments, HTML/text content, headers
- Performance: Concurrent connections, throughput, resource usage
- Security: Authentication, input validation, error handling
The project uses GitHub Actions for automated testing:
- β Code Quality: Formatting, linting, and security audits
- β Cross-Platform: Testing on Linux, macOS, and Windows
- β Performance: Automated benchmarking and regression detection
- β Security: Dependency vulnerability scanning
- β Docker: Container build verification and security scanning
For detailed testing documentation, see TESTING.md.