# Mail server discovery

Not always on the same machine as the agent. Before assuming mail is local:

## Step 1: Check DNS (MX record)

```bash
host -t MX <domain.com>
host <mailhost.domain.com>
```

The MX record reveals the actual mail server host. The A/AAAA records show its IP. If the IP differs from the agent's host, mail is remote.

## Step 2: Check local MTA/IMAP services

```bash
dpkg -l 2>/dev/null | grep -iE 'dovecot|postfix|exim|sendmail|courier'
systemctl list-units --type=service --state=running | grep -iE 'mail|dovecot|postfix|exim'
```

If nothing is installed, mail is definitely remote.

## Step 3: Check for Docker-based mail stacks

```bash
docker ps 2>/dev/null | grep -iE 'mail|dovecot|postfix'
```

## Step 4: Locate mail storage

Common paths for local mail:
- `/var/mail/` — traditional mbox spool
- `/var/vmail/` — virtual maildir (Postfix/Dovecot)
- `/home/vmail/` — alternate virtual maildir
- `/srv/mail/` — manual setup
- `/var/lib/dovecot/` — Dovecot index storage

### When mail is remote

The agent connects via IMAP/SMTP. Disk usage questions are moot — the user must check with their mail hosting provider. The agent can still:
- Connect via IMAP to read/search/move messages
- Send via SMTP
- Check the user's mxrouting.net / mail provider control panel for storage quotas
