> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Manage Mailofly domains, send test emails, and inspect logs directly from your command line.

# Mailofly CLI

The Mailofly CLI allows developers to send emails, manage sending domains, inspect delivery logs, and test webhooks directly from the terminal.

***

## Installation

Run Mailofly on-demand using `npx` or install it globally via npm:

<CodeGroup>
  ```bash npx (Recommended) theme={null}
  npx mailofly --help
  ```

  ```bash Global install theme={null}
  npm install -g mailofly
  ```

  ```bash Homebrew (macOS) theme={null}
  brew install mailofly/tap/mailofly
  ```
</CodeGroup>

***

## Authentication

Log in with your Mailofly API key or browser session:

```bash theme={null}
mailofly login
```

Alternatively, export your API key in your terminal environment:

```bash theme={null}
export MAILOFLY_API_KEY="mf_live_..."
```

***

## Key Commands

### Send a Test Email

Send an email in seconds directly from the CLI:

```bash theme={null}
mailofly send \
  --to "user@example.com" \
  --from "onboarding@yourcompany.com" \
  --subject "Hello from Mailofly CLI" \
  --text "This email was dispatched using the Mailofly command line interface."
```

### Domain Management

List all configured domains and check their DNS verification status:

```bash theme={null}
# List all sending domains
mailofly domains list

# Verify DNS records for a specific domain
mailofly domains verify yourcompany.com
```

### View Live Delivery Logs

Stream or filter delivery events in real time:

```bash theme={null}
# View recent delivery events
mailofly logs --limit 10

# Filter by bounced or suppressed emails
mailofly logs --status bounced
```

### Webhook Forwarding

Tunnel webhook delivery events to your local development server:

```bash theme={null}
mailofly listen --forward-to localhost:3000/api/webhooks/mailofly
```

***

## CLI Options

| Flag            | Short | Description                                   |
| --------------- | ----- | --------------------------------------------- |
| `--api-key`     | `-k`  | Pass Mailofly API key inline                  |
| `--account-key` | `-a`  | Target specific sending account               |
| `--json`        | `-j`  | Format output as JSON for scripting           |
| `--verbose`     | `-v`  | Display raw HTTP request and response headers |
| `--help`        | `-h`  | Display help and usage information            |


## Related topics

- [Unsubscribe Link](/sending/unsubscribe-link.md)
