Juergen Kunz 0018b19164 feat(tests): Port CMD-06 RSET, SEC-06 IP Reputation, and ERR-01 Syntax Error tests
- Ported CMD-06 RSET Command tests with 8 passing tests covering transaction resets and recipient clearing.
- Ported SEC-06 IP Reputation tests with 7 passing tests validating infrastructure and legitimate traffic acceptance.
- Ported ERR-01 Syntax Error tests with 10 passing tests for handling invalid commands and syntax errors.
- Updated README files to reflect the new test statuses and coverage.
- Added detailed test cases for handling invalid sequences in ERR-02 tests.
2025-10-28 10:47:05 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 10:00:25 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 10:00:25 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00
2025-10-24 08:09:29 +00:00

@serve.zone/mailer

Enterprise mail server with SMTP, HTTP API, and DNS management

License Version

Overview

@serve.zone/mailer is a comprehensive mail server solution built with Deno, featuring:

  • SMTP Server & Client - Full-featured SMTP implementation for sending and receiving emails
  • HTTP REST API - Mailgun-compatible API for programmatic email management
  • DNS Management - Automatic DNS setup via Cloudflare API
  • DKIM/SPF/DMARC - Complete email authentication and security
  • Daemon Service - Systemd integration for production deployments
  • CLI Interface - Command-line management of all features

Architecture

Technology Stack

  • Runtime: Deno (compiles to standalone binaries)
  • Language: TypeScript
  • Distribution: npm (via binary wrappers)
  • Service: systemd daemon
  • DNS: Cloudflare API integration

Project Structure

mailer/
├── bin/                    # npm binary wrappers
├── scripts/                # Build scripts
├── ts/                     # TypeScript source
│   ├── mail/              # Email implementation (ported from dcrouter)
│   │   ├── core/          # Email classes, validation, templates
│   │   ├── delivery/      # SMTP client/server, queues
│   │   ├── routing/       # Email routing, domain config
│   │   └── security/      # DKIM, SPF, DMARC
│   ├── api/               # HTTP REST API (Mailgun-compatible)
│   ├── dns/               # DNS management + Cloudflare
│   ├── daemon/            # Systemd service management
│   ├── config/            # Configuration system
│   └── cli/               # Command-line interface
├── test/                  # Test suite
├── deno.json              # Deno configuration
├── package.json           # npm metadata
└── mod.ts                 # Main entry point

Installation

npm install -g @serve.zone/mailer

From source

git clone https://code.foss.global/serve.zone/mailer
cd mailer
deno task compile

Usage

CLI Commands

Service Management

# Start the mailer daemon
sudo mailer service start

# Stop the daemon
sudo mailer service stop

# Restart the daemon
sudo mailer service restart

# Check status
mailer service status

# Enable systemd service
sudo mailer service enable

# Disable systemd service
sudo mailer service disable

Domain Management

# Add a domain
mailer domain add example.com

# Remove a domain
mailer domain remove example.com

# List all domains
mailer domain list

DNS Management

# Auto-configure DNS via Cloudflare
mailer dns setup example.com

# Validate DNS configuration
mailer dns validate example.com

# Show required DNS records
mailer dns show example.com

Sending Email

# Send email via CLI
mailer send \\
  --from sender@example.com \\
  --to recipient@example.com \\
  --subject "Hello" \\
  --text "World"

Configuration

# Show current configuration
mailer config show

# Set configuration value
mailer config set smtpPort 25
mailer config set apiPort 8080
mailer config set hostname mail.example.com

HTTP API

The mailer provides a Mailgun-compatible REST API:

Send Email

POST /v1/messages
Content-Type: application/json

{
  "from": "sender@example.com",
  "to": "recipient@example.com",
  "subject": "Hello",
  "text": "World",
  "html": "<p>World</p>"
}

List Domains

GET /v1/domains

Manage SMTP Credentials

GET /v1/domains/:domain/credentials
POST /v1/domains/:domain/credentials
DELETE /v1/domains/:domain/credentials/:id

Email Events

GET /v1/events

Programmatic Usage

import { Email, SmtpClient } from '@serve.zone/mailer';

// Create an email
const email = new Email({
  from: 'sender@example.com',
  to: 'recipient@example.com',
  subject: 'Hello from Mailer',
  text: 'This is a test email',
  html: '<p>This is a test email</p>',
});

// Send via SMTP
const client = new SmtpClient({
  host: 'smtp.example.com',
  port: 587,
  secure: true,
  auth: {
    user: 'username',
    pass: 'password',
  },
});

await client.sendMail(email);

Configuration

Configuration is stored in ~/.mailer/config.json:

{
  "domains": [
    {
      "domain": "example.com",
      "dnsMode": "external-dns",
      "cloudflare": {
        "apiToken": "your-cloudflare-token"
      }
    }
  ],
  "apiKeys": ["api-key-1", "api-key-2"],
  "smtpPort": 25,
  "apiPort": 8080,
  "hostname": "mail.example.com"
}

DNS Setup

The mailer requires the following DNS records for each domain:

MX Record

Type: MX
Name: @
Value: mail.example.com
Priority: 10
TTL: 3600

A Record

Type: A
Name: mail
Value: <your-server-ip>
TTL: 3600

SPF Record

Type: TXT
Name: @
Value: v=spf1 mx ip4:<your-server-ip> ~all
TTL: 3600

DKIM Record

Type: TXT
Name: default._domainkey
Value: <dkim-public-key>
TTL: 3600

DMARC Record

Type: TXT
Name: _dmarc
Value: v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com
TTL: 3600

Use mailer dns setup <domain> to automatically configure these via Cloudflare.

Development

Prerequisites

  • Deno 1.40+
  • Node.js 14+ (for npm distribution)

Build

# Compile for all platforms
deno task compile

# Run in development mode
deno task dev

# Run tests
deno task test

# Format code
deno task fmt

# Lint code
deno task lint

Ported Components

The mail implementation is ported from dcrouter and adapted for Deno:

  • Email core (Email, EmailValidator, BounceManager, TemplateManager)
  • SMTP Server (with TLS support)
  • SMTP Client (with connection pooling)
  • Email routing and domain management
  • DKIM signing and verification
  • SPF and DMARC validation
  • Delivery queues and rate limiting

Roadmap

Phase 1 - Core Functionality (Current)

  • Project structure and build system
  • Port mail implementation from dcrouter
  • CLI interface
  • Configuration management
  • DNS management basics
  • Cloudflare DNS integration
  • HTTP REST API implementation
  • Systemd service integration

Phase 2 - Production Ready

  • Comprehensive testing
  • Documentation
  • Performance optimization
  • Security hardening
  • Monitoring and logging

Phase 3 - Advanced Features

  • Webhook support
  • Email templates
  • Analytics and reporting
  • Multi-tenancy
  • Load balancing

License

MIT © Serve Zone

Contributing

Contributions are welcome! Please see our contributing guidelines.

Support

Acknowledgments

Description
an mta implementation as TypeScript package, with network side implemented in rust.
Readme 3.7 MiB
Languages
TypeScript 55.1%
Rust 44%
JavaScript 0.9%