# Rules

File, label or forward new email as it arrives.

## mailset rules list

List the rules on your mailboxes, in the order they run.

```bash
mailset rules list [--mailbox <mailbox>]
```

### Flags

- `--mailbox` (\<mailbox\>, optional): Only this mailbox’s rules.

With `--json` it prints a list of [Rule objects](https://mailset.app/docs/api/rules#rule).

Example:

```bash
mailset rules list --mailbox ana@example.com
```

In the API: [POST /v1/rules.list](https://mailset.app/docs/api/rules#rules.list)

## mailset rules add

Add a rule.

```bash
mailset rules add --mailbox <mailbox> [--name <name>] [--from <from>] [--to <to>] [--subject <subject>] [--has-words <has-words>] [--doesnt-have <doesnt-have>] [--has-attachment] [--larger <larger>] [--smaller <smaller>] [--skip-inbox] [--mark-read] [--star] [--label <label>] [--forward <forward>] [--delete] [--never-junk] [--important] [--never-important] [--tab primary|updates|newsletters|promotions|] [--apply-existing]
```

### Flags

- `--mailbox` (\<mailbox\>, required): The mailbox the rule runs on.
- `--name` (\<name\>, optional): A name for the rule, up to 120 characters.
- `--from` (\<from\>, optional): Mail from this sender: an address, a domain or a name.
- `--to` (\<to\>, optional): Mail sent to this address.
- `--subject` (\<subject\>, optional): Mail with these words in its subject.
- `--has-words` (\<has-words\>, optional): Mail with these words anywhere in it.
- `--doesnt-have` (\<doesnt-have\>, optional): Mail without these words.
- `--has-attachment` (flag, optional): Mail that carries a file.
- `--larger` (\<larger\>, optional): Mail larger than this: bytes, or `5M`, `500K`.
- `--smaller` (\<smaller\>, optional): Mail smaller than this: bytes, or `5M`, `500K`.
- `--skip-inbox` (flag, optional): Archive it as it arrives.
- `--mark-read` (flag, optional): Mark it read.
- `--star` (flag, optional): Star it.
- `--label` (\<label\>, optional): Put this label on it, by name.
- `--forward` (\<forward\>, optional): Forward it to this address. Asks for a passkey.
- `--delete` (flag, optional): Move it to Trash.
- `--never-junk` (flag, optional): Never send it to Junk.
- `--important` (flag, optional): Mark it important.
- `--never-important` (flag, optional): Never mark it important. Beats `important`.
- `--tab` (enum, optional): File it in this inbox tab. One of `primary`, `updates`, `newsletters`, `promotions`, ``.
- `--apply-existing` (flag, optional): Also run it over the conversations already here.

It can ask for your passkey. It prints “This needs your passkey. Open <link>”, then waits until the link is approved or refused. Read its output as it comes: through head or tail, the link shows only after the wait.

With `--json` it prints the [Rule object](https://mailset.app/docs/api/rules#rule).

Example:

```bash
mailset rules add --mailbox ana@example.com --from stripe.com --label Finance --skip-inbox
```

In the API: [POST /v1/rules.add](https://mailset.app/docs/api/rules#rules.add)

## mailset rules update

Change a rule.

```bash
mailset rules update <id> [--name <name>] [--from <from>] [--to <to>] [--subject <subject>] [--has-words <has-words>] [--doesnt-have <doesnt-have>] [--has-attachment] [--larger <larger>] [--smaller <smaller>] [--skip-inbox] [--mark-read] [--star] [--label <label>] [--forward <forward>] [--delete] [--never-junk] [--important] [--never-important] [--tab primary|updates|newsletters|promotions|] [--apply-existing]
```

### Flags

- `<id>` (argument, required): The rule’s id, from `rules list`.
- `--name` (\<name\>, optional): A name for the rule, up to 120 characters.
- `--from` (\<from\>, optional): Mail from this sender: an address, a domain or a name.
- `--to` (\<to\>, optional): Mail sent to this address.
- `--subject` (\<subject\>, optional): Mail with these words in its subject.
- `--has-words` (\<has-words\>, optional): Mail with these words anywhere in it.
- `--doesnt-have` (\<doesnt-have\>, optional): Mail without these words.
- `--has-attachment` (flag, optional): Mail that carries a file.
- `--larger` (\<larger\>, optional): Mail larger than this: bytes, or `5M`, `500K`.
- `--smaller` (\<smaller\>, optional): Mail smaller than this: bytes, or `5M`, `500K`.
- `--skip-inbox` (flag, optional): Archive it as it arrives.
- `--mark-read` (flag, optional): Mark it read.
- `--star` (flag, optional): Star it.
- `--label` (\<label\>, optional): Put this label on it, by name.
- `--forward` (\<forward\>, optional): Forward it to this address. Asks for a passkey.
- `--delete` (flag, optional): Move it to Trash.
- `--never-junk` (flag, optional): Never send it to Junk.
- `--important` (flag, optional): Mark it important.
- `--never-important` (flag, optional): Never mark it important. Beats `important`.
- `--tab` (enum, optional): File it in this inbox tab. One of `primary`, `updates`, `newsletters`, `promotions`, ``.
- `--apply-existing` (flag, optional): Also run it over the conversations already here.

It can ask for your passkey. It prints “This needs your passkey. Open <link>”, then waits until the link is approved or refused. Read its output as it comes: through head or tail, the link shows only after the wait.

With `--json` it prints the [Rule object](https://mailset.app/docs/api/rules#rule).

Example:

```bash
mailset rules update rl_1c7e3a9f5b2d4068e4a9c2f1 --label Invoices --mark-read
```

In the API: [POST /v1/rules.update](https://mailset.app/docs/api/rules#rules.update)

## mailset rules remove

Delete a rule.

```bash
mailset rules remove <id>
```

### Flags

- `<id>` (argument, required): The rule’s id, from `rules list`.

With `--json` it prints what [the API returns](https://mailset.app/docs/api/rules#rules.remove-returns).

Example:

```bash
mailset rules remove rl_1c7e3a9f5b2d4068e4a9c2f1
```

In the API: [POST /v1/rules.remove](https://mailset.app/docs/api/rules#rules.remove)

## mailset rules reorder

Set the order a mailbox’s rules run in.

```bash
mailset rules reorder --mailbox <mailbox> --ids <a,b,…>
```

### Flags

- `--mailbox` (\<mailbox\>, required): The mailbox whose rules these are.
- `--ids` (\<a,b,…\>, required): Every rule’s id, in the order they should run. Or @<path>, to read the JSON from a file.

With `--json` it prints a list of [Rule objects](https://mailset.app/docs/api/rules#rule).

Example:

```bash
mailset rules reorder --mailbox ana@example.com --ids rl_9a2f6c1e8b4d3057c1e6a3b8,rl_1c7e3a9f5b2d4068e4a9c2f1
```

In the API: [POST /v1/rules.reorder](https://mailset.app/docs/api/rules#rules.reorder)

## mailset rules test

Show what a rule would match, without doing anything.

```bash
mailset rules test [<id>] [--mailbox <mailbox>] [--name <name>] [--from <from>] [--to <to>] [--subject <subject>] [--has-words <has-words>] [--doesnt-have <doesnt-have>] [--has-attachment] [--larger <larger>] [--smaller <smaller>] [--skip-inbox] [--mark-read] [--star] [--label <label>] [--forward <forward>] [--delete] [--never-junk] [--important] [--never-important] [--tab primary|updates|newsletters|promotions|]
```

### Flags

- `<id>` (argument, optional): A rule you have, by its id. Left out: the flags describe one.
- `--mailbox` (\<mailbox\>, optional): The mailbox to test against, for a rule described by flags.
- `--name` (\<name\>, optional): A name for the rule, up to 120 characters.
- `--from` (\<from\>, optional): Mail from this sender: an address, a domain or a name.
- `--to` (\<to\>, optional): Mail sent to this address.
- `--subject` (\<subject\>, optional): Mail with these words in its subject.
- `--has-words` (\<has-words\>, optional): Mail with these words anywhere in it.
- `--doesnt-have` (\<doesnt-have\>, optional): Mail without these words.
- `--has-attachment` (flag, optional): Mail that carries a file.
- `--larger` (\<larger\>, optional): Mail larger than this: bytes, or `5M`, `500K`.
- `--smaller` (\<smaller\>, optional): Mail smaller than this: bytes, or `5M`, `500K`.
- `--skip-inbox` (flag, optional): Archive it as it arrives.
- `--mark-read` (flag, optional): Mark it read.
- `--star` (flag, optional): Star it.
- `--label` (\<label\>, optional): Put this label on it, by name.
- `--forward` (\<forward\>, optional): Forward it to this address. Asks for a passkey.
- `--delete` (flag, optional): Move it to Trash.
- `--never-junk` (flag, optional): Never send it to Junk.
- `--important` (flag, optional): Mark it important.
- `--never-important` (flag, optional): Never mark it important. Beats `important`.
- `--tab` (enum, optional): File it in this inbox tab. One of `primary`, `updates`, `newsletters`, `promotions`, ``.

With `--json` it prints what [the API returns](https://mailset.app/docs/api/rules#rules.test-returns).

Example:

```bash
mailset rules test --mailbox ana@example.com --from stripe.com
```

In the API: [POST /v1/rules.test](https://mailset.app/docs/api/rules#rules.test)

## mailset rules apply

Run a rule over the conversations already here, in the background.

```bash
mailset rules apply <id>
```

### Flags

- `<id>` (argument, required): The rule’s id, from `rules list`.

With `--json` it prints what [the API returns](https://mailset.app/docs/api/rules#rules.apply-returns).

Example:

```bash
mailset rules apply rl_1c7e3a9f5b2d4068e4a9c2f1
```

In the API: [POST /v1/rules.apply](https://mailset.app/docs/api/rules#rules.apply)

## mailset rules import

Turn a Gmail mailFilters.xml export into rules.

```bash
mailset rules import <mailbox> --file <path>
```

### Flags

- `<mailbox>` (argument, required): The mailbox the rules go on.
- `--file` (\<path\>, required): The file to send, read from this machine.

It can ask for your passkey. It prints “This needs your passkey. Open <link>”, then waits until the link is approved or refused. Read its output as it comes: through head or tail, the link shows only after the wait.

With `--json` it prints what [the API returns](https://mailset.app/docs/api/rules#rules.import-returns).

Example:

```bash
mailset rules import ana@example.com --file mailFilters.xml
```

In the API: [POST /v1/rules.import](https://mailset.app/docs/api/rules#rules.import)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content