Full-stack email server in pure C — SMTP MTA on port 25/587, IMAP4rev1 on port 993, DKIM signing, Maildir storage, TLS via mbedTLS. Zero external dependencies.
scorpiox-server-email is a self-contained email server compiled from a single C source file (scorpiox/scorpiox-server-email.c). It implements a full SMTP Mail Transfer Agent on ports 25 and 587 (submission), an IMAP4rev1 server on port 993 (IMAPS), DKIM signing for outbound messages, Maildir-format storage, and email aliasing — all using mbedTLS for encryption with zero external dependencies.
Source: scorpiox/scorpiox-server-email.c | Type: server | TLS: mbedTLS
Full MTA implementation supporting both relay (port 25) and submission (port 587). Handles EHLO/HELO handshake, MAIL FROM, RCPT TO, DATA, and QUIT commands. STARTTLS upgrade is supported for encrypted submission.
# SMTP session example
telnet mail.example.com 25
EHLO client.example.com
250-mail.example.com
250-STARTTLS
250-AUTH PLAIN LOGIN
250 OK
STARTTLS
220 Ready to start TLS
AUTH PLAIN AG1lQHNjb3JwaW94Lm5ldABwYXNzd29yZA==
235 Authentication successfulIMAP server on port 993 (IMAPS — TLS from connection start). Supports standard IMAP commands: LOGIN, SELECT, EXAMINE, FETCH, SEARCH, STORE, COPY, LIST, LSUB, SUBSCRIBE, UNSUBSCRIBE, and LOGOUT. Mail is stored in Maildir format and served directly from disk.
# IMAP session example (over TLS on port 993)
openssl s_client -connect mail.example.com:993
a1 LOGIN user@example.com password
a1 OK LOGIN completed
a2 SELECT INBOX
* 42 EXISTS
* 0 RECENT
a2 OK [READ-WRITE] SELECT completed
a3 FETCH 1:* (FLAGS ENVELOPE)
a4 LOGOUTAll TLS operations use mbedTLS (embedded in the binary, no OpenSSL dependency). SMTP supports STARTTLS upgrade on port 587. IMAP uses TLS-from-connect on port 993. Certificates and keys are configured via EMAIL_TLS_CERT and EMAIL_TLS_KEY in scorpiox-env.txt.
Complete Mail Transfer Agent on port 25 (relay) and port 587 (submission) with STARTTLS support.
Full IMAP server on port 993 (IMAPS). TLS from connection start. Standard mailbox operations.
Outbound messages are DKIM-signed automatically. Improves deliverability and prevents spoofing.
Industry-standard Maildir format. One file per message. No database, no corruption on crash.
Standard SMTP authentication mechanisms. Credentials verified against the accounts file.
Route messages with aliases. Forward addresses to other accounts without separate mailboxes.
Outbound messages are queued and retried automatically on temporary delivery failures.
Server-side filtering rules for incoming messages. Route, tag, or reject based on headers.
Run interactively with a terminal UI or daemonize for production. PID file management included.
File-based account store. Add, remove, and manage email accounts from the CLI.
All TLS via mbedTLS — compiled in, no OpenSSL, no GnuTLS, no shared library dependencies.
Single C file, single binary. No Postfix, no Dovecot, no Exim. Just compile and run.
All settings go in scorpiox-env.txt in your project root. The server reads these at startup.
| Key | Default | Description |
|---|---|---|
| EMAIL_SMTP_PORT | 25 | SMTP MTA listening port for inbound relay |
| EMAIL_SUBMISSION_PORT | 587 | SMTP submission port (authenticated, STARTTLS) |
| EMAIL_IMAP_PORT | 993 | IMAPS port (TLS from connection start) |
| EMAIL_DOMAIN | — | Primary mail domain (e.g., scorpiox.net) |
| EMAIL_MAILDIR | ./maildir | Root directory for Maildir storage |
| EMAIL_TLS_CERT | — | Path to TLS certificate (PEM format) |
| EMAIL_TLS_KEY | — | Path to TLS private key (PEM format) |
| EMAIL_ACCOUNTS_FILE | ./accounts.txt | File containing user accounts (user:password_hash per line) |
# scorpiox-server-email configuration
EMAIL_DOMAIN=scorpiox.net
EMAIL_SMTP_PORT=25
EMAIL_SUBMISSION_PORT=587
EMAIL_IMAP_PORT=993
EMAIL_MAILDIR=/var/mail/scorpiox
EMAIL_TLS_CERT=/etc/ssl/certs/mail.scorpiox.net.pem
EMAIL_TLS_KEY=/etc/ssl/private/mail.scorpiox.net.key
EMAIL_ACCOUNTS_FILE=/etc/scorpiox/email-accounts.txt# Start scorpiox-server-email as a daemon
sx server-email --daemon
# Start in foreground with TUI
sx server-email
# Check server status
sx server-email --status# Add a new email account
sx server-email --add-account user@scorpiox.net
# List all accounts
sx server-email --list-accounts
# Remove an account
sx server-email --remove-account user@scorpiox.net# Send via the local server
sx email --to admin@scorpiox.net \
--subject "Test from scorpiox-server-email" \
--body "SMTP server is running."
# Send with HTML body from file
sx email --to admin@scorpiox.net \
--subject "Report" \
--html-file report.html# MX record — route mail to your server
scorpiox.net. IN MX 10 mail.scorpiox.net.
# A record for the mail server
mail.scorpiox.net. IN A 203.0.113.10
# SPF — authorize the server to send
scorpiox.net. IN TXT "v=spf1 a:mail.scorpiox.net ~all"
# DKIM — public key for signature verification
sx._domainkey.scorpiox.net. IN TXT "v=DKIM1; k=rsa; p=MIGfMA0..."
# DMARC — policy
_dmarc.scorpiox.net. IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@scorpiox.net"scorpiox-server-email is the server. The corresponding client is scorpiox-email — a lightweight SMTP client built on libcurl that sends mail through any SMTP server, including scorpiox-server-email.
| Client Config Key | Description |
|---|---|
| SMTP_HOST | SMTP server hostname (e.g., mail.scorpiox.net) |
| SMTP_PORT | SMTP port (default: 587) |
| SMTP_USER | Authentication username |
| SMTP_PASS | Authentication password |
| SMTP_FROM | Sender address |
| SMTP_TLS | TLS mode: starttls, ssl, or none |