A high-performance, production-ready SMTP receive-only server powering Cybertemp's temporary and private email infrastructure. Built with Rust for speed, reliability, and concurrency.
๐ฌ Discord
ยท
๐ ChangeLog
ยท
- About
- Architecture
- Features
- Prerequisites
- Installation
- Configuration
- Database Setup
- Running the Server
- How It Works
- Important Notes
- Troubleshooting
- Development Status
- ChangeLog
THIS README IS ENTIRLY GENERATED BY AI I DID NOT WRITE THIS SHIT
This is the actual SMTP server currently powering Cybertemp - a temporary email service handling thousands of emails daily. The codebase is functional and battle-tested in production, though the code quality could use some refactoring (it works, but it's a bit messy ).
This server is designed as a receive-only SMTP server that:
- Accepts incoming emails on port 25 (or custom port)
- Stores temporary emails in PostgreSQL
- Manages inboxes in PostgreSQL (self-hosted)
- Supports private email accounts (optional feature used by Cybertemp)
- Implements domain whitelisting and email/domain banning (optional Supabase integration)
- Handles concurrent connections efficiently with Tokio async runtime
โโโโโโโโโโโโโโโโโโโ
โ Incoming SMTP โ
โ Port 25/2525 โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Rust SMTP Server (Tokio) โ
โ - Concurrent connection handler โ
โ - Email parsing (mailparse) โ
โ - Domain whitelist checking โ
โ - Ban list filtering โ
โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ PostgreSQL โ โ PostgreSQL โ โ Heartbeat โ
โ (Temp Emails) โ โ (Inboxes) โ โ Monitoring โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
- โ Production-Ready: Currently handling Cybertemp's email traffic
- โ High Performance: Async Rust with Tokio for concurrent connections and super fast
- โ Dual Email System: Supports both temporary and private emails
- โ Domain Whitelisting: Accept emails only for configured domains
- โ Ban System: Block emails from specific senders/domains
- โ MIME Parsing: Proper handling of plain text and HTML emails
- โ PostgreSQL Storage: Reliable email storage with indexing
- โ Self-hosted Inboxes: Automatic inbox management in PostgreSQL
- โ Connection Pooling: Efficient database connections
- โ Queue Management: Prevents server overload with request limits
- โ Heartbeat Monitoring: Optional uptime monitoring endpoint
- โ Real-time Domain Updates: Polls for domain/ban updates every 30-60s
- โ Graceful Error Handling: Detailed logging with tracing
- Rust 1.70+ (for compilation)
- PostgreSQL 12+ (for email storage and inbox management)
- Linux/Windows/macOS (any platform supporting Rust)
- Port 25 Access (or alternative SMTP port - requires root/admin on Linux for port 25)
โ ๏ธ Note: The JavaScript version is NOT MAINTAINED. Use the Rust implementation in therust/directory.
-
Install Rust (if not already installed):
# Linux/macOS curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Windows # Download from https://rustup.rs/
-
Clone the repository:
git clone https://github.com/sexfrance/smtp-server.git cd smtp-server/rust -
Build the project:
# Development build cargo build # Production build (optimized) cargo build --release
Create a .env file in the rust/ directory with the following variables:
# PostgreSQL Database (REQUIRED)
DATABASE_URL=postgresql://username:password@localhost:5432/cybertemp
# SMTP Server Settings (OPTIONAL)
SMTP_RECEIVE_PORT=25 # Default: 25 (use 2525 for non-root testing)
# Heartbeat Monitoring (OPTIONAL)
HEARTBEAT_URL=https://your-monitoring-service.com/ping| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
โ Yes | - | PostgreSQL connection string for storing emails |
SMTP_RECEIVE_PORT |
โ No | 25 | SMTP port (default: 25) |
HEARTBEAT_URL |
โ No | - | Uptime monitoring ping URL |
USE_SUPABASE_BANS |
โ No | true | Enable/disable Supabase ban system |
USE_SUPABASE_DOMAINS |
โ No | true | Enable/disable Supabase domain whitelist |
Run the SQL schema located in rust/SQL/schema.sql:
psql -U your_user -d cybertemp -f rust/SQL/schema.sqlThis creates:
emailstable - stores all temporary emailsinboxtable - stores inbox information (self-hosted)private_emailtable - optional private email accounts (see below)- Necessary indexes for performance
If you want to use domain whitelisting and ban management, create these tables in Supabase:
CREATE TABLE domains (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
domain TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Add your domains
INSERT INTO domains (domain) VALUES
('cybertemp.xyz'),
('temp-mail.xyz'),
('*.example.com'); -- Wildcard supportCREATE TABLE bans (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
scope TEXT NOT NULL, -- 'email' or 'domain'
value TEXT NOT NULL, -- email address or domain
match_type TEXT DEFAULT 'exact', -- 'exact' or 'contains'
status TEXT DEFAULT 'active', -- 'active' or 'inactive'
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Example bans
INSERT INTO bans (scope, value, match_type, status) VALUES
('email', 'spam@example.com', 'exact', 'active'),
('email', 'spam', 'contains', 'active'), -- Blocks any email containing "spam"
('domain', 'spammer.com', 'exact', 'active');Note: If you don't create these Supabase tables, set USE_SUPABASE_BANS=false and USE_SUPABASE_DOMAINS=false in your .env file. The server will accept all domains and have no bans by default.
cd rust
cargo runcd rust
cargo build --release
./target/release/cybertemp_smtpPort 25 requires root privileges:
# Option 1: Run as root
sudo ./target/release/cybertemp_smtp
# Option 2: Grant port binding capability (recommended)
sudo setcap CAP_NET_BIND_SERVICE=+eip ./target/release/cybertemp_smtp
./target/release/cybertemp_smtpCreate /etc/systemd/system/cybertemp-smtp.service:
[Unit]
Description=Cybertemp SMTP Server
After=network.target postgresql.service
[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/smtp-server/rust
EnvironmentFile=/path/to/smtp-server/rust/.env
ExecStart=/path/to/smtp-server/rust/target/release/cybertemp_smtp
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl daemon-reload
sudo systemctl enable cybertemp-smtp
sudo systemctl start cybertemp-smtp
sudo systemctl status cybertemp-smtp- Connection: External SMTP server connects to port 25
- SMTP Handshake: Server responds with
220 Cybertemp Mail Receiver - Domain Check: Recipient domain is validated against whitelist
- Ban Check: Sender and domain are checked against ban list
- Email Receipt: Server accepts email data until
.terminator - Parsing: Email is parsed using
mailparsecrate - Storage Decision:
- If recipient is in
private_emailtable โ Store in PostgreSQLemailstable - Otherwise โ Store in PostgreSQL as temporary email + create PostgreSQL inbox entry
- If recipient is in
- Response: Server responds with
250 Ok: Message accepted
The server only accepts emails for domains listed in the configured domain source (Supabase domains table if enabled, otherwise accepts all domains). This prevents abuse and unauthorized usage.
Wildcard support:
example.com- matches exactlyexample.com*.example.com- matchesmail.example.com,temp.example.com, etc.
Automatic updates: Domain list is refreshed every 60 seconds.
Protects against spam and abuse:
- Email bans: Block specific sender addresses
exactmatch: Must match exactlycontainsmatch: Blocks if sender contains substring
- Domain bans: Block entire sending domains
- Real-time updates: Ban list refreshes every 30 seconds
private_email table is ONLY used by Cybertemp for paid features and is NOT required for basic SMTP functionality.
What it does:
- Allows specific email addresses to have persistent storage
- Adds an extra layer of security with passwords
- Used for Cybertemp's paid private email accounts
- Completely optional for self-hosted deployments
How to remove it:
- Delete or ignore
rust/SQL/privatemail.sql - Remove the private email check in
main.rs(lines ~409-447):// Remove this entire block: match sqlx::query("SELECT id FROM private_email WHERE email = $1 LIMIT 1") .bind(&recipient_email) .fetch_optional(postgres_pool) .await { // ... entire private email handling logic }
- Long functions that should be split up
- Some error handling could be more elegant
- Duplicate code in fallback paths
- Comment clutter from debugging sessions
But it works reliably and handles thousands of emails daily for Cybertemp. Refactoring PRs welcome! ๐
javascript/ folder is NOT MAINTAINED - it was an early prototype. Use the Rust version for all deployments.
Problem: Environment variable not being unwrapped properly.
Solution: Make sure .env file exists and contains required variables. The error occurs when env::var() fails.
// Fix by adding .expect() or ?
let database_url = env::var("DATABASE_URL")
.expect("DATABASE_URL must be set in .env file");Check:
- PostgreSQL is running:
systemctl status postgresql - Database exists:
psql -l | grep cybertemp - Credentials are correct in
DATABASE_URL - Schema is initialized:
psql -d cybertemp -c "\dt"
Check:
- Supabase URL is correct (https://your-project.supabase.co)
- Service role key is correct (NOT anon key)
domainstable exists in Supabase- Network connectivity to Supabase
Solution:
# Option 1: Run as root
sudo ./target/release/cybertemp_smtp
# Option 2: Grant capability (Linux only)
sudo setcap CAP_NET_BIND_SERVICE=+eip ./target/release/cybertemp_smtp
# Option 3: Use alternative port
SMTP_RECEIVE_PORT=2525 ./target/release/cybertemp_smtpCheck logs for:
- Domain whitelist rejections
- Ban list rejections
- Database insertion errors
- Parsing errors
Enable debug logging:
RUST_LOG=debug ./target/release/cybertemp_smtp| Component | Status | Notes |
|---|---|---|
| Rust Implementation | โ Active | Production-ready, actively maintained |
| JavaScript Implementation | โ Abandoned | Not maintained, use Rust version |
| PostgreSQL Storage | โ Production | Stable and tested |
| Self-hosted Inboxes | โ Production | No external dependencies |
| Supabase Integration | For advanced features only | |
| Private Email Feature | Cybertemp-specific, not required | |
| Code Quality | Works but messy | |
| Documentation | โ Complete | You're reading it! |
v0.3.0 โฎ 11/01/2025
+ Comprehensive documentation rewrite
+ Clarified private email feature is optional
+ Added extensive troubleshooting guide
+ Documented Supabase table schemas
+ Added systemd service configuration
v0.2.0 โฎ 09/2024
+ Ban system implementation (email/domain blocking)
+ Real-time domain whitelist updates
+ Improved MIME parsing with fallbacks
+ Connection queue management
+ Heartbeat monitoring support
v0.1.0 โฎ 06/2024
! Initial production deployment for Cybertemp
+ PostgreSQL storage implementation
+ Supabase integration
+ Domain whitelisting
+ Private email support
+ Async Tokio runtime- Discord: discord.cyberious.xyz
- Email: support@cybertemp.xyz
- Issues: GitHub Issues
MIT License - See LICENSE file for details
- Built with โค๏ธ for the Cybertemp community
- Powered by Rust ๐ฆ, Tokio, and PostgreSQL
- Optional Supabase integration for advanced features
Currently powering Cybertemp's email infrastructure ๐