---
title: "nextmail imports"
description: "Every command in this namespace, with its arguments, flags and examples."
url: "https://nextmail.sh/docs/cli/reference/imports"
area: "CLI"
category: "Reference"
---

# nextmail imports

Every command in this namespace, with its arguments, flags and examples.

## Commands

### `nextmail imports list`

List one page of mailbox imports

```bash
nextmail imports list [flags]
```

Returns one page of the imports in the workspace, newest first. Each carries its status, the bytes read so far out of the total, and running counts of messages seen, imported, skipped as duplicates, left out by your options and not imported.

A key limited to particular addresses sees only imports into those addresses.

Add `--all` to walk every page: a table on a terminal, one JSON object per line when piped or with `--ndjson`, and one `{ items, hasMore, nextCursor }` document with `--json`. `--max <n>` stops after that many items.

- Scopes: `threads:read`.
- Needs a sign-in.
- Aliases: `ls`.

**Flags**

- `--address-id <value>`: Only imports into this address.
- `--limit <n>` (default `25`): Rows per page, a whole number from 1 to 100. The server defaults to 25.
- `--cursor <value>`: The `nextCursor` from the previous page, an import id. One that names no import this key can see is a 400 `invalid_cursor`.
- `--all`: Fetch every page and stream the items as they arrive.
- `--max <n>`: Stop after this many items. Implies `--all`.
- `--ndjson`: Print every item as one JSON object per line. Implies `--all`

**Examples**

```bash
nextmail imports list
```

With optional flags

```bash
nextmail imports list --limit 50
```

Walk every page and stop after 100 items

```bash
nextmail imports list --all --max 100
```

One JSON object per line when piped

```bash
nextmail imports list --all > imports.ndjson
```

Also available in: API [`GET /imports`](https://nextmail.sh/docs/api/reference/imports#get-imports); TypeScript [`nextmail.imports.list()`](https://nextmail.sh/docs/sdk/reference/imports#list); Python [`imports.list()`](https://nextmail.sh/docs/python/reference/imports#list); Ruby [`imports.list`](https://nextmail.sh/docs/ruby/reference/imports#list); PHP [`imports->list`](https://nextmail.sh/docs/php/reference/imports#list); Go [`Imports.List`](https://nextmail.sh/docs/go/reference/imports#list); Java [`imports().list`](https://nextmail.sh/docs/java/reference/imports#list); C# [`Imports.ListAsync`](https://nextmail.sh/docs/csharp/reference/imports#list).

### `nextmail imports get`

Read one mailbox import

```bash
nextmail imports get <id> [flags]
```

Resolves one import with its status, byte progress and counts. Poll it while `status` is `queued` or `running`; it settles on `completed`, `failed` or `cancelled`.

An import from a live mailbox has `source` `imap` or `microsoft` and carries `remote`, with the folders done out of the total and why it waits, and `children`, the contacts and calendar imports that came with it. Such an import can also wait: `parked` carries on by itself at `remote.resumeAt`, and `needs-password` stays until `resume` sends a new password. An import from files has `source: file`, `remote: null` and no `children`.

An id from another workspace answers exactly like one that never existed, with 404.

- Scopes: `threads:read`.
- Needs a sign-in.
- Aliases: `show`, `view`.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
nextmail imports get imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail imports get imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}`](https://nextmail.sh/docs/api/reference/imports#get-imports-id); TypeScript [`nextmail.imports.get()`](https://nextmail.sh/docs/sdk/reference/imports#get); Python [`imports.get()`](https://nextmail.sh/docs/python/reference/imports#get); Ruby [`imports.get`](https://nextmail.sh/docs/ruby/reference/imports#get); PHP [`imports->get`](https://nextmail.sh/docs/php/reference/imports#get); Go [`Imports.Get`](https://nextmail.sh/docs/go/reference/imports#get); Java [`imports().get`](https://nextmail.sh/docs/java/reference/imports#get); C# [`Imports.GetAsync`](https://nextmail.sh/docs/csharp/reference/imports#get).

### `nextmail imports create`

Create a mailbox import and get its upload plan

```bash
nextmail imports create --address-id <value> --files <json|@file|-> [flags]
nextmail imports create --data <json|@file|-> [flags]
```

Creates an import into one address of the workspace and returns it with `status: uploading`. Each file is uploaded in parts of `chunkBytes`, `files[i].chunks` of them, through `uploadChunk`, and `start` then queues the import.

The import reads Google Takeout archives, .mbox files from Apple Mail, Thunderbird and most desktop apps, .eml files, and .zip or .tgz archives holding any of those, up to 100 GB a file and 50 files an import. Threads, dates and labels come across. Imported mail is quiet: it runs no rules, forwards, notifications, summaries or webhooks.

`importFiles` does create, upload and start in one call.

- Scopes: `threads:write`.
- Needs a sign-in.
- Aliases: `new`, `add`.

**Flags**

- `--address-id <value>`: The address the mail belongs to. It must be an address this workspace owns and this key may act for. Required, here or in `--data`.
- `--files <json|@file|->`: Each file as `{ name, bytes }`, 1 to 50 of them, each at most 100 GB. JSON shaped as `Array<ImportFileDescriptor>`, inline or from a file with @path. Required, here or in `--data`.
- `--options-keep-inbox`: Default true: mail that was in the old inbox lands in Inbox with its unread state. False files everything under Archive.
- `--options-include-spam`: Default false.
- `--options-include-trash`: Default false.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
nextmail imports create --address-id addr_2b7e --files @files.json
```

Read the whole body from a JSON file

```bash
nextmail imports create --data @import.json
```

Also available in: API [`POST /imports`](https://nextmail.sh/docs/api/reference/imports#post-imports); TypeScript [`nextmail.imports.create()`](https://nextmail.sh/docs/sdk/reference/imports#create); Python [`imports.create()`](https://nextmail.sh/docs/python/reference/imports#create); Ruby [`imports.create`](https://nextmail.sh/docs/ruby/reference/imports#create); PHP [`imports->create`](https://nextmail.sh/docs/php/reference/imports#create); Go [`Imports.Create`](https://nextmail.sh/docs/go/reference/imports#create); Java [`imports().create`](https://nextmail.sh/docs/java/reference/imports#create); C# [`Imports.CreateAsync`](https://nextmail.sh/docs/csharp/reference/imports#create).

### `nextmail imports upload-state`

See which parts of the upload have arrived

```bash
nextmail imports upload-state <id> [flags]
```

For each file, the indexes of the parts already stored, so an interrupted upload sends only what is missing. Empty once the import has left the `uploading` state.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
nextmail imports upload-state imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail imports upload-state imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}/upload`](https://nextmail.sh/docs/api/reference/imports#get-imports-id-upload); TypeScript [`nextmail.imports.uploadState()`](https://nextmail.sh/docs/sdk/reference/imports#uploadState); Python [`imports.upload_state()`](https://nextmail.sh/docs/python/reference/imports#uploadState); Ruby [`imports.upload_state`](https://nextmail.sh/docs/ruby/reference/imports#uploadState); PHP [`imports->uploadState`](https://nextmail.sh/docs/php/reference/imports#uploadState); Go [`Imports.UploadState`](https://nextmail.sh/docs/go/reference/imports#uploadState); Java [`imports().uploadState`](https://nextmail.sh/docs/java/reference/imports#uploadState); C# [`Imports.UploadStateAsync`](https://nextmail.sh/docs/csharp/reference/imports#uploadState).

### `nextmail imports upload-chunk`

Upload one part of an import file

```bash
nextmail imports upload-chunk <id> <file> <chunk> <data> [flags]
```

Stores one part of file `file`: the bytes from `chunk * chunkBytes` up to the next part. Every part is exactly `chunkBytes` long except the last, and a part of the wrong length is 400 `bad_chunk`. Sending a part again replaces it, so a failed part can simply be retried.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.
- `<file>` (required): The file index, in the order given to `create`.
- `<chunk>` (required): The part index, from 0.
- `<data>` (required): The part as a `Blob`, `Uint8Array` or `ArrayBuffer`.

**Examples**

```bash
nextmail imports upload-chunk imp_3f9c2a7b1e4d8f60a5c7b92d 1 1 ./photo.jpg
```

Print the raw JSON

```bash
nextmail imports upload-chunk imp_3f9c2a7b1e4d8f60a5c7b92d 1 1 ./photo.jpg --json
```

Also available in: API [`PUT /imports/{id}/files/{file}/chunks/{chunk}`](https://nextmail.sh/docs/api/reference/imports#put-imports-id-files-file-chunks-chunk); TypeScript [`nextmail.imports.uploadChunk()`](https://nextmail.sh/docs/sdk/reference/imports#uploadChunk); Python [`imports.upload_chunk()`](https://nextmail.sh/docs/python/reference/imports#uploadChunk); Ruby [`imports.upload_chunk`](https://nextmail.sh/docs/ruby/reference/imports#uploadChunk); PHP [`imports->uploadChunk`](https://nextmail.sh/docs/php/reference/imports#uploadChunk); Go [`Imports.UploadChunk`](https://nextmail.sh/docs/go/reference/imports#uploadChunk); Java [`imports().uploadChunk`](https://nextmail.sh/docs/java/reference/imports#uploadChunk); C# [`Imports.UploadChunkAsync`](https://nextmail.sh/docs/csharp/reference/imports#uploadChunk).

### `nextmail imports start`

Queue an import once its files are uploaded

```bash
nextmail imports start <id> [flags]
```

Checks that every part of every file has arrived, recognises each file's format and queues the import. A file still missing parts is 412 `missing_chunks`, and a file that is not an archive or a mailbox is 400 `unsupported_file`. Calling it on an import that has already left `uploading` returns it unchanged.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
nextmail imports start imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail imports start imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`POST /imports/{id}/start`](https://nextmail.sh/docs/api/reference/imports#post-imports-id-start); TypeScript [`nextmail.imports.start()`](https://nextmail.sh/docs/sdk/reference/imports#start); Python [`imports.start()`](https://nextmail.sh/docs/python/reference/imports#start); Ruby [`imports.start`](https://nextmail.sh/docs/ruby/reference/imports#start); PHP [`imports->start`](https://nextmail.sh/docs/php/reference/imports#start); Go [`Imports.Start`](https://nextmail.sh/docs/go/reference/imports#start); Java [`imports().start`](https://nextmail.sh/docs/java/reference/imports#start); C# [`Imports.StartAsync`](https://nextmail.sh/docs/csharp/reference/imports#start).

### `nextmail imports cancel`

Cancel a mailbox import

```bash
nextmail imports cancel <id> [flags]
```

Stops an import at its next checkpoint. Mail already imported stays in the mailbox. A finished import is 409 `not_cancellable`.

- Scopes: `threads:write`.
- Needs a sign-in.
- Asks you to confirm.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
nextmail imports cancel imp_3f9c2a7b1e4d8f60a5c7b92d
```

Skip the confirmation, for scripts

```bash
nextmail imports cancel imp_3f9c2a7b1e4d8f60a5c7b92d --yes
```

Also available in: API [`POST /imports/{id}/cancel`](https://nextmail.sh/docs/api/reference/imports#post-imports-id-cancel); TypeScript [`nextmail.imports.cancel()`](https://nextmail.sh/docs/sdk/reference/imports#cancel); Python [`imports.cancel()`](https://nextmail.sh/docs/python/reference/imports#cancel); Ruby [`imports.cancel`](https://nextmail.sh/docs/ruby/reference/imports#cancel); PHP [`imports->cancel`](https://nextmail.sh/docs/php/reference/imports#cancel); Go [`Imports.Cancel`](https://nextmail.sh/docs/go/reference/imports#cancel); Java [`imports().cancel`](https://nextmail.sh/docs/java/reference/imports#cancel); C# [`Imports.CancelAsync`](https://nextmail.sh/docs/csharp/reference/imports#cancel).

### `nextmail imports list-failures`

List what an import could not bring across

```bash
nextmail imports list-failures <id> [flags]
```

Each message or archive entry that did not come across, with the reason: `too-large` (over 50 MB), `unparseable`, `no-date`, `storage-error`, `unreadable-entry`, `encrypted-entry` or `archive-limit`. Page with `after`, passing the `nextCursor` of the previous page.

- Scopes: `threads:read`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Flags**

- `--after <n>`: The `nextCursor` of the previous page.
- `--limit <n>`: At most 100, the default.

**Examples**

```bash
nextmail imports list-failures imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail imports list-failures imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`GET /imports/{id}/failures`](https://nextmail.sh/docs/api/reference/imports#get-imports-id-failures); TypeScript [`nextmail.imports.listFailures()`](https://nextmail.sh/docs/sdk/reference/imports#listFailures); Python [`imports.list_failures()`](https://nextmail.sh/docs/python/reference/imports#listFailures); Ruby [`imports.list_failures`](https://nextmail.sh/docs/ruby/reference/imports#listFailures); PHP [`imports->listFailures`](https://nextmail.sh/docs/php/reference/imports#listFailures); Go [`Imports.ListFailures`](https://nextmail.sh/docs/go/reference/imports#listFailures); Java [`imports().listFailures`](https://nextmail.sh/docs/java/reference/imports#listFailures); C# [`Imports.ListFailuresAsync`](https://nextmail.sh/docs/csharp/reference/imports#listFailures).

### `nextmail imports delete-upload`

Delete the files uploaded for an import

```bash
nextmail imports delete-upload <id> [flags]
```

Removes the uploaded archive. Mail already imported stays in the mailbox. An import still uploading is cancelled at the same time, and one that is queued or running is 409 `still_running`.

- Scopes: `threads:write`.
- Needs a sign-in.
- Asks you to confirm.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Examples**

```bash
nextmail imports delete-upload imp_3f9c2a7b1e4d8f60a5c7b92d
```

Skip the confirmation, for scripts

```bash
nextmail imports delete-upload imp_3f9c2a7b1e4d8f60a5c7b92d --yes
```

Also available in: API [`DELETE /imports/{id}/upload`](https://nextmail.sh/docs/api/reference/imports#delete-imports-id-upload); TypeScript [`nextmail.imports.deleteUpload()`](https://nextmail.sh/docs/sdk/reference/imports#deleteUpload); Python [`imports.delete_upload()`](https://nextmail.sh/docs/python/reference/imports#deleteUpload); Ruby [`imports.delete_upload`](https://nextmail.sh/docs/ruby/reference/imports#deleteUpload); PHP [`imports->deleteUpload`](https://nextmail.sh/docs/php/reference/imports#deleteUpload); Go [`Imports.DeleteUpload`](https://nextmail.sh/docs/go/reference/imports#deleteUpload); Java [`imports().deleteUpload`](https://nextmail.sh/docs/java/reference/imports#deleteUpload); C# [`Imports.DeleteUploadAsync`](https://nextmail.sh/docs/csharp/reference/imports#deleteUpload).

### `nextmail imports import-files`

Create, upload and start an import in one call

```bash
nextmail imports import-files --address-id <value> --files <path> [flags]
nextmail imports import-files --data <json|@file|-> [flags]
```

Creates the import, uploads every file part by part and starts it, reporting progress through `onProgress`. Pass each file as a `Blob`, `Uint8Array` or `ArrayBuffer`; parts are sliced from it, so a `Blob` backed by a file on disk is never read into memory at once.

It resolves once the import is queued. Poll `get` to follow it.

- Scopes: `threads:write`.
- Needs a sign-in.

**Flags**

- `--address-id <value>`: The address the mail belongs to. Required, here or in `--data`.
- `--files <path>` (repeatable): Each file as `{ name, data }`. Required, here or in `--data`.
- `--options <json|@file|->`: `keepInbox`, `includeSpam` and `includeTrash`, as for `create`. JSON shaped as `ImportOptions`, inline or from a file with @path.
- `--data <json|@file|->`: The whole `input` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
nextmail imports import-files --address-id addr_2b7e --files ./takeout.zip
```

Read the whole body from a JSON file

```bash
nextmail imports import-files --data @import.json
```

Also available in: API [`POST /imports`](https://nextmail.sh/docs/api/reference/imports#post-imports); TypeScript [`nextmail.imports.importFiles()`](https://nextmail.sh/docs/sdk/reference/imports#importFiles); Python [`imports.import_files()`](https://nextmail.sh/docs/python/reference/imports#importFiles); Ruby [`imports.import_files`](https://nextmail.sh/docs/ruby/reference/imports#importFiles); PHP [`imports->importFiles`](https://nextmail.sh/docs/php/reference/imports#importFiles); Go [`Imports.ImportFiles`](https://nextmail.sh/docs/go/reference/imports#importFiles); Java [`imports().importFiles`](https://nextmail.sh/docs/java/reference/imports#importFiles); C# [`Imports.ImportFilesAsync`](https://nextmail.sh/docs/csharp/reference/imports#importFiles).

### `nextmail imports discover-mailbox`

Find the mail server for an address

```bash
nextmail imports discover-mailbox <email> [flags]
```

Looks up where the mailbox behind an address lives, so an import can connect to it. It tries the providers Nextmail knows, then who receives mail for the domain, then Mozilla's public list of mail settings, then the domain's own `_imaps._tcp` record. Nothing is stored and no sign-in is attempted.

`server` is null when nothing was found: ask for the host and port and pass them to `checkMailbox`. `signIn` says what the mailbox takes. `app-password` and `password` are what `checkMailbox` and `connectMailbox` send. An Outlook.com or Microsoft 365 mailbox answers `microsoft`, which only the Microsoft sign-in on the Migrations page of the app can open.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<email>` (required): The address of the old mailbox.

**Examples**

```bash
nextmail imports discover-mailbox ada@gmail.com
```

Print the raw JSON

```bash
nextmail imports discover-mailbox ada@gmail.com --json
```

Also available in: API [`GET /imports/mailbox-settings`](https://nextmail.sh/docs/api/reference/imports#get-imports-mailbox-settings); TypeScript [`nextmail.imports.discoverMailbox()`](https://nextmail.sh/docs/sdk/reference/imports#discoverMailbox); Python [`imports.discover_mailbox()`](https://nextmail.sh/docs/python/reference/imports#discoverMailbox); Ruby [`imports.discover_mailbox`](https://nextmail.sh/docs/ruby/reference/imports#discoverMailbox); PHP [`imports->discoverMailbox`](https://nextmail.sh/docs/php/reference/imports#discoverMailbox); Go [`Imports.DiscoverMailbox`](https://nextmail.sh/docs/go/reference/imports#discoverMailbox); Java [`imports().discoverMailbox`](https://nextmail.sh/docs/java/reference/imports#discoverMailbox); C# [`Imports.DiscoverMailboxAsync`](https://nextmail.sh/docs/csharp/reference/imports#discoverMailbox).

### `nextmail imports check-mailbox`

Check a mailbox before importing it

```bash
nextmail imports check-mailbox --email <value> --password <value> [flags]
nextmail imports check-mailbox --data <json|@file|-> [flags]
```

Signs in to the old mailbox over IMAP, lists its folders and counts the messages, then signs out. Nothing is stored, the password is not kept and the old mailbox is not changed. Use it to show what an import would bring before starting one.

Leave `host` out to have the server looked up from the address, as `discoverMailbox` does. Only port 993 with TLS, or port 143 with STARTTLS, is accepted. Each person may make 10 sign-in attempts an hour across `checkMailbox`, `connectMailbox` and `resume`, and every refused sign-in reads the same, whatever the reason.

- Scopes: `threads:write`.
- Needs a sign-in.

**Flags**

- `--email <value>`: The address of the old mailbox. Required, here or in `--data`.
- `--password <value>`: The password of the old mailbox, or an app password where `discoverMailbox` answers `signIn: app-password`. Pass - to read it from standard input, or @path to read it from a file, so it stays out of your shell history. Required, here or in `--data`.
- `--host <value>`: The IMAP host, such as `imap.example.com`. It has to be a public host. Left out, the server is looked up from the address.
- `--port <n>`: 993 or 143, read only with `host`. Left out, it follows `security`: 993 for `tls` and 143 for `starttls`.
- `--security <value>`: `tls` or `starttls`, read only with `host`. Left out, it follows `port`, and is `tls` when both are left out.
- `--username <value>`: The name to sign in with. Left out, it is the `username` that `discoverMailbox` answers, usually the address.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
nextmail imports check-mailbox --email ada@gmail.com --password @password.txt
```

Read the whole body from a JSON file

```bash
nextmail imports check-mailbox --data @import.json
```

Also available in: API [`POST /imports/mailbox/check`](https://nextmail.sh/docs/api/reference/imports#post-imports-mailbox-check); TypeScript [`nextmail.imports.checkMailbox()`](https://nextmail.sh/docs/sdk/reference/imports#checkMailbox); Python [`imports.check_mailbox()`](https://nextmail.sh/docs/python/reference/imports#checkMailbox); Ruby [`imports.check_mailbox`](https://nextmail.sh/docs/ruby/reference/imports#checkMailbox); PHP [`imports->checkMailbox`](https://nextmail.sh/docs/php/reference/imports#checkMailbox); Go [`Imports.CheckMailbox`](https://nextmail.sh/docs/go/reference/imports#checkMailbox); Java [`imports().checkMailbox`](https://nextmail.sh/docs/java/reference/imports#checkMailbox); C# [`Imports.CheckMailboxAsync`](https://nextmail.sh/docs/csharp/reference/imports#checkMailbox).

### `nextmail imports connect-mailbox`

Import a live mailbox

```bash
nextmail imports connect-mailbox --address-id <value> --email <value> --password <value> [flags]
nextmail imports connect-mailbox --data <json|@file|-> [flags]
```

Starts copying an old mailbox into one address, straight from its mail server. It signs in once to check the password, keeps the password sealed until the import finishes and for 30 days at most, and queues the import. Poll `get` for progress.

The old mailbox is only ever read. Folders become labels, read and starred state come across, and a message the address already holds is skipped, so running an import twice adds nothing. A Gmail mailbox is read from All Mail, with its labels. An import waits by itself when the old provider slows it down, such as Gmail's daily download limit, and carries on from the same folder afterwards: `status` is `parked` and `remote.resumeAt` says when. If the password stops working, `status` is `needs-password` until `resume` sends a new one.

`contacts` and `calendars` bring those across too where the provider offers them, which needs `contacts:write` and `calendar:write` as well. They arrive as contacts and calendar imports of their own, listed in `children`. `--rerun-of` names a finished import of the same mailbox, at most 30 days old, so only mail that arrived since is fetched. One import may run into an address at a time.

- Scopes: `threads:write`.
- Needs a sign-in.

**Flags**

- `--address-id <value>`: The address the mail belongs to. It must be an address this workspace owns and this key may act for. Required, here or in `--data`.
- `--email <value>`: The address of the old mailbox. Required, here or in `--data`.
- `--password <value>`: The password of the old mailbox, or an app password where `discoverMailbox` answers `signIn: app-password`. Pass - to read it from standard input, or @path to read it from a file, so it stays out of your shell history. Required, here or in `--data`.
- `--host <value>`: The IMAP host, such as `imap.example.com`. It has to be a public host. Left out, the server is looked up from the address.
- `--port <n>`: 993 or 143, read only with `host`. Left out, it follows `security`: 993 for `tls` and 143 for `starttls`.
- `--security <value>`: `tls` or `starttls`, read only with `host`. Left out, it follows `port`, and is `tls` when both are left out.
- `--username <value>`: The name to sign in with. Left out, it is the `username` that `discoverMailbox` answers, usually the address.
- `--options-keep-inbox`: Default true: mail that was in the old inbox lands in Inbox with its unread state. False files everything under Archive.
- `--options-include-spam`: Default false.
- `--options-include-trash`: Default false.
- `--contacts`: True brings the address book across too, where the provider offers it. Needs `contacts:write`.
- `--calendars`: True brings the calendars across too, where the provider offers them. Needs `calendar:write`.
- `--rerun-of <value>`: The id of a finished import of the same mailbox, at most 30 days old. Only mail that arrived since is fetched.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

The required values only

```bash
nextmail imports connect-mailbox --address-id addr_2b7e --email ada@gmail.com --password @password.txt
```

With optional flags

```bash
nextmail imports connect-mailbox --address-id addr_2b7e --email ada@gmail.com --password @password.txt --contacts --calendars
```

Read the whole body from a JSON file

```bash
nextmail imports connect-mailbox --data @import.json
```

Also available in: API [`POST /imports/mailbox`](https://nextmail.sh/docs/api/reference/imports#post-imports-mailbox); TypeScript [`nextmail.imports.connectMailbox()`](https://nextmail.sh/docs/sdk/reference/imports#connectMailbox); Python [`imports.connect_mailbox()`](https://nextmail.sh/docs/python/reference/imports#connectMailbox); Ruby [`imports.connect_mailbox`](https://nextmail.sh/docs/ruby/reference/imports#connectMailbox); PHP [`imports->connectMailbox`](https://nextmail.sh/docs/php/reference/imports#connectMailbox); Go [`Imports.ConnectMailbox`](https://nextmail.sh/docs/go/reference/imports#connectMailbox); Java [`imports().connectMailbox`](https://nextmail.sh/docs/java/reference/imports#connectMailbox); C# [`Imports.ConnectMailboxAsync`](https://nextmail.sh/docs/csharp/reference/imports#connectMailbox).

### `nextmail imports resume`

Resume a waiting mailbox import

```bash
nextmail imports resume <id> [flags]
```

Carries on an import from a live mailbox that is waiting. One with `status: parked` is queued again at once, without a body. One with `status: needs-password` needs the new `password`, which is checked against the old mailbox before the import is queued. It picks up at the folder and message it stopped at.

An import that came from a Microsoft sign-in is resumed by signing in again on the Migrations page of the app.

- Scopes: `threads:write`.
- Needs a sign-in.

**Arguments**

- `<id>` (required): Import id, `imp_` followed by 24 hex characters.

**Flags**

- `--password <value>`: The new password of the old mailbox. Required when `status` is `needs-password`. Pass - to read it from standard input, or @path to read it from a file, so it stays out of your shell history.
- `--data <json|@file|->`: The whole `body` as JSON, inline, from a file with @path, or - for standard input. Flags override its keys.

**Examples**

```bash
nextmail imports resume imp_3f9c2a7b1e4d8f60a5c7b92d
```

Print the raw JSON

```bash
nextmail imports resume imp_3f9c2a7b1e4d8f60a5c7b92d --json
```

Also available in: API [`POST /imports/{id}/resume`](https://nextmail.sh/docs/api/reference/imports#post-imports-id-resume); TypeScript [`nextmail.imports.resume()`](https://nextmail.sh/docs/sdk/reference/imports#resume); Python [`imports.resume()`](https://nextmail.sh/docs/python/reference/imports#resume); Ruby [`imports.resume`](https://nextmail.sh/docs/ruby/reference/imports#resume); PHP [`imports->resume`](https://nextmail.sh/docs/php/reference/imports#resume); Go [`Imports.Resume`](https://nextmail.sh/docs/go/reference/imports#resume); Java [`imports().resume`](https://nextmail.sh/docs/java/reference/imports#resume); C# [`Imports.ResumeAsync`](https://nextmail.sh/docs/csharp/reference/imports#resume).
