# Module: aliases
#
# Email aliases resolution and local domains management
#
# This module provides:
# - Unix-style aliases resolution (/etc/aliases format)
# - Virtual aliases (Postfix virtual format)
# - Local domain detection
# - Message classification (inbound/outbound/internal)
# - Service-specific rules (Gmail, plus-aliases)
# - Forwarding detection
#
# Documentation: https://rspamd.com/doc/modules/aliases.html

aliases {
  # Enable/disable the module (enabled by default since 3.14.2)
  # enabled = true;

  # System aliases (Unix /etc/aliases format)
  # Can be:
  #  - Simple path: "/etc/aliases"
  #  - Table with type: {type = "file"; path = "/etc/aliases"}
  #  - Map: {type = "map"; url = "file:///etc/aliases"}
  #  - CDB: {type = "cdb"; path = "/var/lib/rspamd/aliases.cdb"}
  #
  # system_aliases = "/etc/aliases";

  # Virtual aliases (Postfix virtual format)
  # Same backend options as system_aliases
  #
  # virtual_aliases = "/etc/postfix/virtual";

  # Local domains (domains we handle locally)
  # Can be:
  #  - Array: ["example.com", "mail.example.com"]
  #  - File path: "/etc/rspamd/local_domains.list"
  #  - Table with backend config
  #
  # local_domains = [
  #   "example.com",
  #   "mail.example.com"
  # ];
  #
  # Or load from file:
  # local_domains = "/etc/rspamd/local_domains.list";
  #
  # Or use Postfix mydestination:
  # local_domains = "/etc/postfix/mydestination";

  # Rspamd-specific aliases (inline configuration)
  # Format: "alias" = "target" or "alias" = ["target1", "target2"]
  #
  # rspamd_aliases = {
  #   "support@example.com" = "support-team@example.com";
  #   "sales@example.com" = ["user1@example.com", "user2@example.com"];
  # }

  # Resolution options
  max_recursion_depth = 10;      # Maximum recursion depth for alias resolution
  expand_multiple = true;        # Expand 1->N aliases (one alias to multiple targets)
  track_chain = false;           # Track full resolution chain (for debugging)

  # Apply alias resolution to which parts
  apply_to_mime = true;          # Apply to MIME from/to headers
  apply_to_smtp = true;          # Apply to SMTP envelope

  # Service-specific rules
  enable_gmail_rules = true;     # Enable Gmail-specific rules (dot removal, plus addressing)
  enable_plus_aliases = true;    # Enable generic plus addressing (user+tag@domain)

  # Symbol configuration
  # These symbols are inserted based on message classification
  symbol_local_inbound = "LOCAL_INBOUND";     # Mail from external to local domain
  symbol_local_outbound = "LOCAL_OUTBOUND";   # Mail from local to external domain
  symbol_internal_mail = "INTERNAL_MAIL";     # Mail from local to local
  symbol_alias_resolved = "ALIAS_RESOLVED";   # Address was resolved through aliases
  symbol_tagged_from = "TAGGED_FROM";         # From address has plus-tags
  symbol_tagged_rcpt = "TAGGED_RCPT";         # Recipient has plus-tags

  # Symbol scores (0.0 = informational only)
  score_local_inbound = 0.0;
  score_local_outbound = 0.0;
  score_internal_mail = 0.0;
  score_alias_resolved = 0.0;
  score_tagged_from = 0.0;
  score_tagged_rcpt = 0.0;

  .include(try=true,priority=5) "${DBDIR}/dynamic/aliases.conf"
  .include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/aliases.conf"
  .include(try=true,priority=10) "$LOCAL_CONFDIR/override.d/aliases.conf"
}
