Skip to the content.

Configuration

GoSMTP-dup can be configured using YAML files or environment variables.

Configuration File

Create a config.yaml file:

# SMTP server configuration
smtp:
  # Address and port where the SMTP duplicator will listen for incoming connections
  listen: "127.0.0.1:2525"

  # Domain name that the SMTP server announces itself as
  # This appears in the SMTP greeting (220 response) and server identification
  domain: "localhost"

# Email relay configuration
relay:
  # Primary destination server (REQUIRED)
  # Emails are sent here synchronously - if this fails, the original send fails
  destination_primary: "mailprimary.example.com:25"

  # Backup destination servers (OPTIONAL)
  # Emails are duplicated to these servers asynchronously in the background
  # Failures here are logged but don't affect the client
  destination_backups:
    - "mail_backup1.example.com:25"
    - "mail_backup2.example.com:25"

  # Timeout in seconds for relay operations
  timeout_seconds: 10

Configuration Locations

The application searches for configuration files in:

  1. Current directory (./config.yaml)
  2. /etc/smtp-dup/config.yaml

Configuration Options

Option Type Required Description
smtp.listen string Yes Address and port for SMTP server
smtp.domain string Yes Domain name for SMTP server identification
relay.destination_primary string Yes Primary mail server (synchronous)
relay.destination_backups array No Backup mail servers (asynchronous)
relay.timeout_seconds integer No Timeout for relay operations (default: 10)

Behavior

Primary Destination

Backup Destinations

Timeout

Example Configurations

Minimal Configuration

smtp:
  listen: "0.0.0.0:2525"
  domain: "mail.example.com"
relay:
  destination_primary: "newmail.example.com:25"

Migration Configuration

smtp:
  listen: "0.0.0.0:2525"
  domain: "mail.example.com"
relay:
  destination_primary: "oldmail.example.com:25"  # Current production
  destination_backups:
    - "newmail.example.com:25"    # Migration target
    - "archive.example.com:25"    # Archive server
  timeout_seconds: 30

Migration Flow Diagram

sequenceDiagram
    participant C as Email Client
    participant P as Postfix
    participant D as GoSMTP-dup
    participant O as Old Mail Server
    participant N as New Mail Server
    participant A as Archive Server

    C->>P: Send Email
    P->>D: Route via Transport Map

    par Synchronous (Primary)
        D->>O: Send Email
        O->>D: βœ… Success/❌ Failure
    and Asynchronous (Backups)
        D->>N: Send Email (Background)
        D->>A: Send Email (Background)
        N-->>D: Result (Logged)
        A-->>D: Result (Logged)
    end

    D->>P: Primary Response
    P->>C: Final Response

    Note over D,N: Migration target receives<br/>copy for testing
    Note over D,A: Archive server stores<br/>all emails safely

High Availability Configuration

smtp:
  listen: "0.0.0.0:2525"
  domain: "mail.example.com"
relay:
  destination_primary: "primary.example.com:25"
  destination_backups:
    - "backup1.example.com:25"
    - "backup2.example.com:25"
    - "backup3.example.com:25"
  timeout_seconds: 15
← Back: Installation Next: Environment Variables β†’