# Email Feature Configuration - Example Environment
# Complete documentation of all email system options

[features]
email = true

[email]
enabled = true
provider = "smtp"                         # Email provider: smtp, sendgrid, mailgun, ses, console
from_email = "noreply@example.com"        # Default sender email address
from_name = "Example Application"         # Default sender name
reply_to = "support@example.com"          # Default reply-to address
bounce_address = "bounce@example.com"     # Bounce handling address
templates_dir = "templates/email"         # Email templates directory
queue_enabled = true                      # Enable email queue
max_retries = 3                           # Maximum retry attempts for failed emails
retry_delay = 300                         # Retry delay in seconds (5 minutes)
max_queue_size = 10000                    # Maximum queue size
batch_size = 100                          # Batch size for sending emails
rate_limit = 100                          # Rate limit (emails per minute)
timeout = 30                              # Email sending timeout in seconds

[email.smtp]
host = "smtp.example.com"                 # SMTP server hostname
port = 587                                # SMTP server port
username = "your-username"                # SMTP authentication username
password = "your-password"                # SMTP authentication password (use env var)
use_tls = true                            # Use TLS encryption
use_starttls = true                       # Use STARTTLS
auth_mechanism = "login"                  # Authentication mechanism: login, plain, cram-md5
connection_timeout = 30                   # Connection timeout in seconds
read_timeout = 30                         # Read timeout in seconds
write_timeout = 30                        # Write timeout in seconds
pool_size = 10                            # Connection pool size
pool_timeout = 30                         # Pool timeout in seconds
keepalive = true                          # Enable keepalive
verify_certificate = true                 # Verify SSL certificate

[email.sendgrid]
api_key = "your-sendgrid-api-key"        # SendGrid API key (use env var)
endpoint = "https://api.sendgrid.com/v3/mail/send"  # SendGrid API endpoint
sandbox_mode = false                      # Enable sandbox mode for testing
tracking_enabled = true                   # Enable email tracking
click_tracking = true                     # Enable click tracking
open_tracking = true                      # Enable open tracking
subscription_tracking = false             # Enable subscription tracking
ganalytics_enabled = false                # Enable Google Analytics tracking

[email.mailgun]
api_key = "your-mailgun-api-key"         # Mailgun API key (use env var)
domain = "your-domain.com"               # Mailgun domain
endpoint = "https://api.mailgun.net/v3"  # Mailgun API endpoint
eu_region = false                         # Use EU region
test_mode = false                         # Enable test mode
tracking_enabled = true                   # Enable email tracking
click_tracking = true                     # Enable click tracking
open_tracking = true                      # Enable open tracking
delivery_time = false                     # Enable delivery time optimization

[email.ses]
region = "us-east-1"                      # AWS SES region
access_key_id = "your-access-key"        # AWS access key ID (use env var)
secret_access_key = "your-secret-key"    # AWS secret access key (use env var)
configuration_set = ""                    # SES configuration set
source_arn = ""                           # Source ARN for sending authorization
tags = {}                                 # Default tags for emails
template_tags = {}                        # Default template tags

[email.console]
enabled_in_dev = true                     # Enable console output in development
log_level = "info"                        # Log level for console output
pretty_print = true                       # Pretty print email content
show_headers = true                       # Show email headers
show_body = true                          # Show email body
show_attachments = true                   # Show attachment info

[email.templates]
engine = "handlebars"                     # Template engine: handlebars, tera, minijinja
cache_enabled = true                      # Cache compiled templates
cache_ttl = 3600                          # Template cache TTL in seconds
cache_size = 1000                         # Maximum cached templates
auto_reload = true                        # Auto-reload templates in development
default_language = "en"                   # Default template language
supported_languages = ["en", "es", "fr", "de"]  # Supported languages
fallback_language = "en"                  # Fallback language
template_validation = true                # Validate templates on load
minify_html = true                        # Minify HTML templates
inline_css = true                         # Inline CSS in HTML emails

[email.queue]
backend = "redis"                         # Queue backend: redis, database, memory
redis_url = "redis://localhost:6379"     # Redis URL for queue storage
redis_db = 2                              # Redis database number
redis_key_prefix = "email_queue:"         # Redis key prefix
database_table = "email_queue"            # Database table for queue
max_attempts = 5                          # Maximum delivery attempts
retry_backoff = "exponential"             # Retry backoff strategy: linear, exponential
min_retry_delay = 60                      # Minimum retry delay in seconds
max_retry_delay = 3600                    # Maximum retry delay in seconds
dead_letter_queue = true                  # Enable dead letter queue
cleanup_interval = 3600                   # Queue cleanup interval in seconds
job_timeout = 300                         # Job timeout in seconds

[email.notifications]
enabled = true                            # Enable email notifications
delivery_notifications = true             # Send delivery notifications
bounce_notifications = true               # Send bounce notifications
complaint_notifications = true            # Send complaint notifications
webhook_enabled = true                    # Enable webhook notifications
webhook_url = "https://example.com/webhook"  # Webhook URL
webhook_secret = "your-webhook-secret"    # Webhook secret for verification
webhook_events = [                        # Webhook events to send
    "delivered", "bounced", "complained", "clicked", "opened"
]

[email.tracking]
enabled = true                            # Enable email tracking
pixel_tracking = true                     # Enable pixel tracking for opens
link_tracking = true                      # Enable link tracking for clicks
bounce_tracking = true                    # Enable bounce tracking
complaint_tracking = true                 # Enable complaint tracking
unsubscribe_tracking = true               # Enable unsubscribe tracking
analytics_integration = true              # Enable analytics integration
retention_days = 90                       # Tracking data retention in days

[email.security]
dkim_enabled = true                       # Enable DKIM signing
dkim_domain = "example.com"               # DKIM domain
dkim_selector = "default"                 # DKIM selector
dkim_private_key_path = "/path/to/private.key"  # DKIM private key path
spf_enabled = true                        # Enable SPF checking
dmarc_enabled = true                      # Enable DMARC
tls_required = true                       # Require TLS for sending
content_filtering = true                  # Enable content filtering
spam_filtering = true                     # Enable spam filtering
virus_scanning = false                    # Enable virus scanning
encryption_enabled = false                # Enable email encryption
pgp_enabled = false                       # Enable PGP encryption

[email.validation]
enabled = true                            # Enable email validation
syntax_validation = true                  # Validate email syntax
domain_validation = true                  # Validate domain existence
mx_validation = true                      # Validate MX records
disposable_email_detection = true         # Detect disposable emails
role_email_detection = true               # Detect role-based emails
typo_detection = true                     # Detect common typos
blacklist_enabled = true                  # Enable email blacklist
whitelist_enabled = false                 # Enable email whitelist
blacklist_domains = [                     # Blacklisted domains
    "tempmail.com", "10minutemail.com", "guerrillamail.com"
]

[email.attachments]
enabled = true                            # Enable email attachments
max_size = 25165824                       # Maximum attachment size (24MB)
max_count = 10                            # Maximum number of attachments
allowed_types = [                         # Allowed attachment types
    "pdf", "doc", "docx", "txt", "jpg", "jpeg", "png", "gif"
]
blocked_types = [                         # Blocked attachment types
    "exe", "bat", "cmd", "com", "scr", "pif", "vbs", "js"
]
virus_scan = false                        # Scan attachments for viruses
compression = true                        # Enable attachment compression
encryption = false                        # Enable attachment encryption
storage_backend = "filesystem"            # Storage backend: filesystem, s3, gcs
storage_path = "attachments"              # Storage path for attachments

[email.lists]
enabled = true                            # Enable mailing lists
max_subscribers = 10000                   # Maximum subscribers per list
double_opt_in = true                      # Require double opt-in
unsubscribe_link = true                   # Include unsubscribe link
list_unsubscribe_header = true            # Include List-Unsubscribe header
bounce_handling = true                    # Handle bounces automatically
complaint_handling = true                 # Handle complaints automatically
segmentation = true                       # Enable list segmentation
personalization = true                    # Enable email personalization
a_b_testing = true                        # Enable A/B testing
automation = true                         # Enable email automation

[email.campaigns]
enabled = true                            # Enable email campaigns
scheduling = true                         # Enable campaign scheduling
recurring_campaigns = true                # Enable recurring campaigns
drip_campaigns = true                     # Enable drip campaigns
trigger_campaigns = true                  # Enable trigger-based campaigns
analytics = true                          # Enable campaign analytics
reporting = true                          # Enable campaign reporting
export_data = true                        # Enable data export
archive_campaigns = true                  # Archive old campaigns
campaign_templates = true                 # Enable campaign templates

[email.compliance]
gdpr_compliance = true                    # Enable GDPR compliance
can_spam_compliance = true                # Enable CAN-SPAM compliance
casl_compliance = false                   # Enable CASL compliance
data_retention_days = 2555                # Data retention period (7 years)
consent_tracking = true                   # Track consent
opt_out_handling = true                   # Handle opt-out requests
data_export = true                        # Enable data export for users
data_deletion = true                      # Enable data deletion for users
privacy_policy_link = "https://example.com/privacy"  # Privacy policy link
terms_of_service_link = "https://example.com/terms"  # Terms of service link

[email.monitoring]
enabled = true                            # Enable email monitoring
health_checks = true                      # Enable health checks
performance_monitoring = true             # Monitor email performance
error_tracking = true                     # Track email errors
delivery_monitoring = true                # Monitor delivery rates
bounce_monitoring = true                  # Monitor bounce rates
complaint_monitoring = true               # Monitor complaint rates
reputation_monitoring = true              # Monitor sender reputation
alerting = true                           # Enable alerting

[email.monitoring.alert_thresholds]
bounce_rate = 5.0                         # Bounce rate threshold (%)
complaint_rate = 0.1                      # Complaint rate threshold (%)
delivery_rate = 95.0                      # Minimum delivery rate (%)
queue_size = 1000                         # Queue size threshold

[email.testing]
test_mode = false                         # Enable test mode
test_recipients = ["test@example.com"]    # Test recipients
test_prefix = "[TEST]"                    # Test email prefix
sandbox_mode = false                      # Enable sandbox mode
mock_delivery = false                     # Mock email delivery
test_templates = true                     # Enable template testing
preview_mode = true                       # Enable email preview
lint_templates = true                     # Lint email templates
validation_testing = true                 # Test email validation
load_testing = false                      # Enable load testing

[email.logging]
enabled = true                            # Enable email logging
log_level = "info"                        # Log level
log_format = "json"                       # Log format: json, plain
log_file = "logs/email.log"               # Log file path
log_rotation = true                       # Enable log rotation
max_log_size = 104857600                  # Maximum log file size (100MB)
max_log_files = 10                        # Maximum log files to keep
log_emails = false                        # Log email content (privacy concern)
log_headers = true                        # Log email headers
log_delivery = true                       # Log delivery status
log_bounces = true                        # Log bounces
log_complaints = true                     # Log complaints
log_clicks = true                         # Log clicks
log_opens = true                          # Log opens

[email.performance]
connection_pooling = true                 # Enable connection pooling
persistent_connections = true             # Use persistent connections
compression = true                        # Enable compression
caching = true                            # Enable response caching
async_sending = true                      # Enable async email sending
batch_sending = true                      # Enable batch sending
queue_optimization = true                 # Enable queue optimization
lazy_loading = true                       # Enable lazy loading
precompiled_templates = true              # Use precompiled templates
cdn_integration = false                   # Enable CDN for email assets
