# Scan Inbox Emails

Escape assigns a dedicated inbox email address to each scan profile, allowing your application to send emails during security tests. The `emails` commands let you list, read, and wait for emails received at those scan inbox addresses.

## Scan Email Address Format

Each scan inbox address belongs to your organization and follows this format:

```text
<alias>.<mailboxId>@scan.escape.tech
```

| Part | Description |
| --- | --- |
| `<alias>` | 1-27 ASCII letters, digits, and hyphens; dots allowed only between characters |
| `<mailboxId>` | Your organization's 6-character mailbox ID (lowercase Crockford base32) |
| `@scan.escape.tech` | Fixed domain |

Open [Organization → General](<https://app.escape.tech/organization/general/>) in the Escape app. The **Scan Email Address** field shows how your inbox address is built: edit the alias on the left, copy the suffix (mailbox ID and domain) on the right.

The full organization UUID suffix is still accepted for existing configurations.

With mailbox ID `abc123`, these addresses are valid:

- `user1.abc123@scan.escape.tech`
- `admin.abc123@scan.escape.tech`
- `test-alice.abc123@scan.escape.tech`

Use a different alias for each configured user.

For scan email setup in authentication presets, see [Scan email addresses](<https://docs.escape.tech/documentation/platform/authentication/multi-factor-authentication/#scan-email-addresses>).

## Listing Inbox Emails

List emails received at a scan inbox address.

```bash
escape-cli emails list --email <inbox-address> [flags]
```

### Options

| Flag | Description | Format |
| --- | --- | --- |
| `--email` | Target inbox email address (**required**) | Scan inbox address |
| `--before` | Only include emails created before this timestamp | RFC3339 (for example 2026-01-15T09:00:00Z) |
| `--after` | Only include emails created after this timestamp | RFC3339 |
| `--limit` | Maximum number of emails to return | Positive integer |

### Examples

```bash
# List all emails for a scan inbox
escape-cli emails list --email test.abc123@scan.escape.tech

# Limit to 10 results
escape-cli emails list --email test.abc123@scan.escape.tech --limit 10

# Filter by date
escape-cli emails list --email test.abc123@scan.escape.tech \
  --after 2026-04-15T16:47:32Z

# Export to JSON
escape-cli emails list --email test.abc123@scan.escape.tech -o json
```

**Example Output:**

```text
ID                                    CREATED AT                FROM                      SUBJECT
11111111-1111-1111-1111-111111111111  2026-04-16T12:30:00Z      noreply@example.com       Password Reset
22222222-2222-2222-2222-222222222222  2026-04-16T12:25:00Z      alerts@example.com        Verification Code
```

## Reading an Email

Fetch the full content of a specific inbox email by ID.

```bash
escape-cli emails read <email-id>
```

**Aliases:** `read`, `get`, `show`

### Examples

```bash
# Read an email
escape-cli emails read 11111111-1111-1111-1111-111111111111

# Read in JSON format
escape-cli emails read 11111111-1111-1111-1111-111111111111 -o json
```

**Example Output:**

```text
ID: 11111111-1111-1111-1111-111111111111
CREATED AT: 2026-04-16T12:30:00Z
FROM: noreply@example.com
SUBJECT: Password Reset

BODY:
Click the link below to reset your password...
```

## Waiting for a New Email

Block until the next new email is received at a scan inbox address. This is useful for automated test flows that trigger an email and need to consume the result.

```bash
escape-cli emails wait --email <inbox-address> [flags]
```

### Options

| Flag | Description | Default |
| --- | --- | --- |
| `--email` | Target inbox email address (**required**) |  |
| `--timeout` | Maximum time to wait before failing (for example `30s`, `2m`) | No timeout |
| `--poll-interval` | Delay between inbox polls | `2s` |

### Examples

```bash
# Wait indefinitely for the next email
escape-cli emails wait --email test.abc123@scan.escape.tech

# Wait with a 2-minute timeout
escape-cli emails wait --email test.abc123@scan.escape.tech --timeout 2m

# Poll every second instead of every 2 seconds
escape-cli emails wait --email test.abc123@scan.escape.tech --poll-interval 1s

# Capture the result as JSON
escape-cli emails wait --email test.abc123@scan.escape.tech -o json
```

The `wait` command snapshots the current inbox state, then polls for any new email that wasn't present at the time the command started. Once a new email arrives, its full content is printed and the command exits.

## Automation Example

Use `emails wait` inside a scan workflow to verify that your application sends the expected email:

```bash
#!/bin/bash
set -e

INBOX="test.abc123@scan.escape.tech"

# Start the scan that triggers an email
SCAN_ID=$(escape-cli scans start "${PROFILE_ID}" -o json | jq -r '.id')

# Wait for the triggered email (timeout after 60 seconds)
EMAIL=$(escape-cli emails wait --email "$INBOX" --timeout 60s -o json)

# Extract and verify the email subject
SUBJECT=$(echo "$EMAIL" | jq -r '.subject')
echo "Received email: $SUBJECT"
```
