maddy

package module
v0.8.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2025 License: GPL-3.0 Imports: 60 Imported by: 0

README ΒΆ

Maddy Chatmail Server

Optimized all-in-one mail server for instant, secure messaging

This is a specialized fork of Maddy Mail Server optimized specifically for chatmail deployments. It provides a single binary solution for running secure, encrypted-only email servers designed for Delta Chat and similar messaging applications.

What is Chatmail?

Chatmail servers are email servers optimized for secure messaging rather than traditional email. They prioritize:

  • Instant account creation without personal information
  • Encryption-only messaging to ensure privacy
  • Automatic cleanup to minimize data retention
  • Low maintenance for easy deployment

Key Features

βœ… Implemented
  • Passwordless onboarding: Users can create accounts instantly via QR codes
  • Encrypted messages only (outbound): Prevents sending unencrypted messages to external recipients
  • Single binary deployment: Everything needed in one executable
  • Delta Chat integration: Native support for Delta Chat account creation
  • Web interface: Simple account creation and management interface
🚧 Planned Features
  • Encrypted messages only (inbound): Filter incoming unencrypted messages
  • Automatic message cleanup: Remove messages unconditionally after N days (currently 20 days)
  • Stale account cleanup: Remove inactive addresses after M days without login
  • Push notifications: Metadata support for real-time messaging
  • Enhanced monitoring: Better observability for chatmail-specific metrics

Live Example

See a working deployment at: inja.bid

This demonstrates the complete chatmail experience including:

  • Instant account creation via QR code
  • Web interface for account management
  • Full Delta Chat integration

Quick Start

Docker Compose with Caddy Reverse Proxy

The easiest way to get started with automatic SSL management is using Docker Compose with Caddy as a reverse proxy. This setup handles SSL certificates automatically and proxies requests to Maddy Chatmail.

First, create a Caddyfile:

yourdomain.com, mail.yourdomain.com {
  # Proxy both the main and mail subdomain to the chatmail web endpoint
  reverse_proxy maddy-chatmail:8080
}

Then, create a docker-compose.yml file:


services:
  caddy:
    image: caddy:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    restart: unless-stopped

  maddy-chatmail:
    image: ghcr.io/sadraiiali/maddy_chatmail:latest
    environment:
      # MADDY_HOSTNAME: hostname used for SMTP/IMAP MX and TLS
      - MADDY_HOSTNAME=mail.yourdomain.com
      # MADDY_DOMAIN: primary domain served by this instance
      - MADDY_DOMAIN=yourdomain.com
    volumes:
      - maddy-data:/data
      - ./maddy.conf:/data/maddy.conf:ro  # put a custom maddy.conf here (chatmail endpoint on port 8080)
    depends_on:
      - caddy
    restart: unless-stopped

volumes:
  maddy-data:
  caddy_data:
  caddy_config:

Create a custom maddy.conf based on the setup guide, but change the chatmail endpoints to use port 8080:

# ... (same as setup guide but modify chatmail endpoints)

# Chatmail endpoint for user registration
chatmail tcp://0.0.0.0:8080 {
    mail_domain $(primary_domain)
    mx_domain $(hostname)
    web_domain $(primary_domain)
    auth_db local_authdb
    storage local_mailboxes
}

Run it with:

docker-compose up -d

Caddy will automatically obtain SSL certificates for your domain and proxy requests to Maddy Chatmail.

Notes
  • Make sure DNS A/AAAA records for yourdomain.com and mail.yourdomain.com point to the server running Caddy.
  • Open ports 80 and 443 on the host so Caddy can perform ACME challenges and serve TLS.
  • The example expects the chatmail HTTP endpoint to listen on port 8080 inside the maddy-chatmail container (see the chatmail endpoint example below).

For detailed setup instructions including manual installation, TLS certificates, and DNS configuration, see the Setup Guide.

Releases & Downloads

Pre-built release artifacts for common platforms are published on the repository's GitHub Releases page. Each release includes signed archives for the following targets (when available):

  • linux (amd64, arm64)
  • macOS (amd64, arm64)
  • windows (amd64, arm64)

To download the latest release, visit: https://github.com/sadraiiali/maddy_chatmail/releases and pick the artifact matching your OS/architecture. Artifacts are packaged as tar.gz (Linux/macOS) or zip (Windows) and include a maddy binary and the default maddy.conf.

If you prefer to build locally, see the "Building from source" tutorial in the docs (it also documents how to use the releases and how to embed version information): docs/tutorials/building-from-source.md

Configuration Differences from Standard Maddy

This chatmail-optimized version includes:

  1. Simplified Configuration: Pre-configured for chatmail use cases
  2. Chatmail Endpoint: Built-in HTTP/HTTPS endpoints for account creation
  3. Encryption Enforcement: Automatic blocking of unencrypted outbound messages
  4. Account Management: Streamlined user creation and cleanup processes
  5. Delta Chat Integration: Native QR code generation and account provisioning

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Interface β”‚    β”‚   SMTP/IMAP      β”‚    β”‚   Delta Chat    β”‚
β”‚   (QR Codes)    │◄──►│   Mail Server    │◄──►│   Clients       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   SQLite Storage β”‚
                    β”‚   (Accounts &    β”‚
                    β”‚    Messages)     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Contributing

This project maintains compatibility with the upstream Maddy project while adding chatmail-specific optimizations. Contributions should:

  1. Maintain backward compatibility with standard Maddy configurations
  2. Follow the chatmail specification and best practices
  3. Include tests for new chatmail-specific features
  4. Update documentation for any user-facing changes

Upstream Compatibility

This fork periodically syncs with the upstream Maddy project to incorporate security updates and improvements. Chatmail-specific features are implemented as optional modules that don't interfere with standard Maddy functionality.

License

This project inherits the GPL-3.0 license from the upstream Maddy Mail Server project.


For traditional email server needs, consider using the upstream Maddy Mail Server project.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	SDReady     = "READY=1"
	SDReloading = "RELOADING=1"
	SDStopping  = "STOPPING=1"
)

Variables ΒΆ

View Source
var (
	// ConfigDirectory specifies platform-specific value
	// that should be used as a location of default configuration
	//
	// It should not be changed and is defined as a variable
	// only for purposes of modification using -X linker flag.
	ConfigDirectory = "/etc/maddy"

	// DefaultStateDirectory specifies platform-specific
	// default for StateDirectory.
	//
	// Most code should use StateDirectory instead since
	// it will contain the effective location of the state
	// directory.
	//
	// It should not be changed and is defined as a variable
	// only for purposes of modification using -X linker flag.
	DefaultStateDirectory = "/var/lib/maddy"

	// DefaultRuntimeDirectory specifies platform-specific
	// default for RuntimeDirectory.
	//
	// Most code should use RuntimeDirectory instead since
	// it will contain the effective location of the state
	// directory.
	//
	// It should not be changed and is defined as a variable
	// only for purposes of modification using -X linker flag.
	DefaultRuntimeDirectory = "/run/maddy"

	// DefaultLibexecDirectory specifies platform-specific
	// default for LibexecDirectory.
	//
	// Most code should use LibexecDirectory since it will
	// contain the effective location of the libexec
	// directory.
	//
	// It should not be changed and is defined as a variable
	// only for purposes of modification using -X linker flag.
	DefaultLibexecDirectory = "/usr/lib/maddy"
)
View Source
var ErrNoNotifySock = errors.New("no systemd socket")
View Source
var (
	Version = "go-build"
)

Functions ΒΆ

func BuildInfo ΒΆ

func BuildInfo() string

func InitDirs ΒΆ

func InitDirs() error

func LogOutputOption ΒΆ

func LogOutputOption(args []string) (log.Output, error)

func ReadGlobals ΒΆ

func ReadGlobals(cfg []config.Node) (map[string]interface{}, []config.Node, error)

func Run ΒΆ

func Run(c *cli.Context) error

Run is the entry point for all server-running code. It takes care of command line arguments processing, logging initialization, directives setup, configuration reading. After all that, it calls moduleMain to initialize and run modules.

Types ΒΆ

type ModInfo ΒΆ

type ModInfo struct {
	Instance module.Module
	Cfg      config.Node
}

func RegisterModules ΒΆ

func RegisterModules(globals map[string]interface{}, nodes []config.Node) (endpoints, mods []ModInfo, err error)

type SDStatus ΒΆ

type SDStatus string

Directories ΒΆ

Path Synopsis
cmd
maddy command
framework
address
Package address provides utilities for parsing and validation of RFC 2821 addresses.
Package address provides utilities for parsing and validation of RFC 2821 addresses.
buffer
The buffer package provides utilities for temporary storage (buffering) of large blobs.
The buffer package provides utilities for temporary storage (buffering) of large blobs.
cfgparser
Package config provides set of utilities for configuration parsing.
Package config provides set of utilities for configuration parsing.
config/module
Package modconfig provides matchers for config.Map that query modules registry and parse inline module definitions.
Package modconfig provides matchers for config.Map that query modules registry and parse inline module definitions.
dns
Package dns defines interfaces used by maddy modules to perform DNS lookups.
Package dns defines interfaces used by maddy modules to perform DNS lookups.
exterrors
Package errors defines error-handling and primitives used across maddy, notably to pass additional error information across module boundaries.
Package errors defines error-handling and primitives used across maddy, notably to pass additional error information across module boundaries.
log
Package log implements a minimalistic logging library.
Package log implements a minimalistic logging library.
logparser
Package parser provides utilities for parsing of structured log messsages generated by maddy.
Package parser provides utilities for parsing of structured log messsages generated by maddy.
module
Package module contains modules registry and interfaces implemented by modules.
Package module contains modules registry and interfaces implemented by modules.
internal
auth/shadow
shadow package implements utilities for parsing and using shadow password database on Unix systems.
shadow package implements utilities for parsing and using shadow password database on Unix systems.
cli
dsn
Package dsn contains the utilities used for dsn message (DSN) generation.
Package dsn contains the utilities used for dsn message (DSN) generation.
limits
Package limit provides a module object that can be used to restrict the concurrency and rate of the messages flow globally or on per-source, per-destination basis.
Package limit provides a module object that can be used to restrict the concurrency and rate of the messages flow globally or on per-source, per-destination basis.
limits/limiters
Package limiters provides a set of wrappers intended to restrict the amount of resources consumed by the server.
Package limiters provides a set of wrappers intended to restrict the amount of resources consumed by the server.
smtpconn
Package smtpconn contains the code shared between target.smtp and remote modules.
Package smtpconn contains the code shared between target.smtp and remote modules.
storage/imapsql
Package imapsql implements SQL-based storage module using go-imap-sql library (github.com/foxcpp/go-imap-sql).
Package imapsql implements SQL-based storage module using go-imap-sql library (github.com/foxcpp/go-imap-sql).
target/queue
Package queue implements module which keeps messages on disk and tries delivery to the configured target (usually remote) multiple times until all recipients are succeeded.
Package queue implements module which keeps messages on disk and tries delivery to the configured target (usually remote) multiple times until all recipients are succeeded.
target/remote
Package remote implements module which does outgoing message delivery using servers discovered using DNS MX records.
Package remote implements module which does outgoing message delivery using servers discovered using DNS MX records.
target/smtp
Package smtp_downstream provides target.smtp module that implements transparent forwarding or messages to configured list of SMTP servers.
Package smtp_downstream provides target.smtp module that implements transparent forwarding or messages to configured list of SMTP servers.
tls
updatepipe
Package updatepipe implements utilities for serialization and transport of IMAP update objects between processes and machines.
Package updatepipe implements utilities for serialization and transport of IMAP update objects between processes and machines.
Package tests provides the framework for integration testing of maddy.
Package tests provides the framework for integration testing of maddy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL