Zimbra Mail Flow
This skill should be used when the user asks about "Postfix configuration", "mail queue", "content filter", "mail routing", "amavisd", "milter", "SMTP relay", "mail delivery", "MTA settings", "message flow", or mentions mail transport issues with Zimbra. Provides guidance for mail flow configuration and troubleshooting.
What this skill does
# Zimbra Mail Flow
Guide for configuring and troubleshooting mail flow in Zimbra, including Postfix integration, content filtering, and queue management.
## Architecture Overview
Zimbra uses Postfix as its MTA (Mail Transfer Agent):
```
Internet → Proxy (nginx) → Postfix → Content Filter → Postfix → Mailbox
↓
amavisd-new
↓
SpamAssassin/ClamAV
```
### Components
- **Postfix** - SMTP server for sending and receiving mail
- **amavisd-new** - Content filter interface
- **SpamAssassin** - Spam detection
- **ClamAV** - Antivirus scanning
- **policyd** - Policy daemon for rate limiting
## Postfix Configuration
### Key Configuration Files
| File | Purpose |
|------|---------|
| `/opt/zimbra/common/conf/main.cf` | Main Postfix config |
| `/opt/zimbra/common/conf/master.cf` | Service definitions |
| `/opt/zimbra/conf/zmconfigd/smtpd.cf` | SMTP daemon config |
### View/Modify Settings
```bash
# View current setting
postconf content_filter
# View all settings
postconf -n
# Modify setting (as zimbra user)
zmprov ms $(hostname) zimbraMtaContentFilter "smtp-amavis:[127.0.0.1]:10024"
# Direct postconf (may be overwritten by Zimbra)
postconf -e "content_filter = smtp-amavis:[127.0.0.1]:10024"
# Reload after changes
postfix reload
```
### Common Settings via zmprov
```bash
# Content filter
zmprov ms mail.domain.com zimbraMtaContentFilter "smtp-amavis:[127.0.0.1]:10024"
# Relay host
zmprov ms mail.domain.com zimbraMtaRelayHost "smtp.relay.com:25"
# Message size limit (bytes)
zmprov ms mail.domain.com zimbraMtaMaxMessageSize 52428800
# SMTP authentication
zmprov ms mail.domain.com zimbraMtaSaslAuthEnable TRUE
```
## Content Filtering
### Default Flow
1. Mail arrives on port 25
2. Postfix sends to amavisd on port 10024
3. amavisd processes (spam/virus check)
4. Clean mail returns to Postfix on port 10025
5. Postfix delivers to mailbox
### Custom Content Filter
To add a custom content filter (e.g., policy server):
```bash
# Check port availability FIRST
netstat -tlnp | grep 2525
# Add service to master.cf
postconf -Me "policy-filter/unix = policy-filter unix - n n - 10 smtp -o smtp_send_xforward_command=yes"
# Set content filter
zmprov ms $(hostname) zimbraMtaContentFilter "smtp:[127.0.0.1]:2525"
# Reload MTA
zmcontrol restart mta
```
### Bypass Content Filter
For specific senders/recipients:
```bash
# Create transport map
echo "[email protected] :" >> /opt/zimbra/conf/transport
# Rebuild and reload
postmap /opt/zimbra/conf/transport
postfix reload
```
## Queue Management
### View Queue
```bash
# Queue summary
mailq
# Detailed queue listing
postqueue -p
# Count messages
mailq | tail -n 1
```
### Manage Queue
```bash
# Flush queue (attempt redelivery)
postqueue -f
# Delete specific message
postsuper -d <queue-id>
# Delete all queued messages
postsuper -d ALL
# Hold message
postsuper -h <queue-id>
# Release held message
postsuper -H <queue-id>
# Requeue message
postsuper -r <queue-id>
```
### View Message Content
```bash
# Find message in queue
find /opt/zimbra/data/postfix/spool -name "<queue-id>"
# View message headers
postcat -q <queue-id> | head -50
# View full message
postcat -q <queue-id>
```
## Troubleshooting
### Check MTA Status
```bash
# Service status
zmmtactl status
# Postfix status
postfix status
# Check listening ports
netstat -tlnp | grep -E "(25|465|587|10024|10025)"
```
### Log Analysis
```bash
# Main mail log
tail -f /var/log/zimbra.log
# Postfix log
tail -f /opt/zimbra/log/zimbra.log | grep postfix
# Track message by ID
grep <message-id> /var/log/zimbra.log
```
### Common Issues
#### Mail Stuck in Queue
```bash
# Check queue reason
postqueue -p | grep -A 2 <queue-id>
# Check DNS
host -t mx recipient-domain.com
# Check relay connectivity
telnet relay.host.com 25
```
#### Content Filter Not Working
```bash
# Verify amavisd running
zmamavisdctl status
# Check content_filter setting
postconf content_filter
# Verify ports
netstat -tlnp | grep 10024
netstat -tlnp | grep 10025
```
#### SMTP Authentication Failing
```bash
# Check SASL config
postconf smtpd_sasl_auth_enable
# Test auth
openssl s_client -connect mail.domain.com:465 -quiet
AUTH LOGIN
```
## Relay Configuration
### Outbound Relay
```bash
# Set relay host
zmprov ms $(hostname) zimbraMtaRelayHost "smtp.relay.com:25"
# With authentication
zmprov ms $(hostname) zimbraMtaRelayHost "[smtp.relay.com]:587"
zmprov ms $(hostname) zimbraMtaSaslAuthEnable TRUE
# Configure credentials in sasl_passwd
echo "[smtp.relay.com]:587 username:password" >> /opt/zimbra/conf/sasl_passwd
postmap /opt/zimbra/conf/sasl_passwd
```
### Inbound Relay (Accept from specific hosts)
```bash
# Add to mynetworks
zmprov ms $(hostname) +zimbraMtaMyNetworks "192.168.1.0/24"
# Reload
postfix reload
```
## Rate Limiting
### Using cbpolicyd
```bash
# Check status
zmcbpolicydctl status
# View policies
sqlite3 /opt/zimbra/data/cbpolicyd/db/cbpolicyd.sqlitedb \
"SELECT * FROM policies;"
# Common rate limit (via admin console or direct SQL)
# Limit 100 messages per hour per sender
```
## Additional Resources
### Reference Files
- **`references/postfix-settings.md`** - Complete Postfix parameter reference
- **`references/amavisd-config.md`** - amavisd configuration options
### Example Files
- **`examples/custom-content-filter.sh`** - Setup custom filter
- **`examples/transport-map.sh`** - Configure transport routing
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.