# Moving a mailbox in

You arrive with ten years of mail elsewhere: it comes in here, with its dates, its folders and what you had already read. The job is done with **imapsync**, the standard tool of the trade, which speaks to any IMAP mailbox.

## 1. Open a migration window

On [suite.simafri.com](https://suite.simafri.com/), **Mail settings**, **Move a mailbox in** section, click **Open a migration**.

For **twenty-four hours**, your other account can pour its mail into this mailbox; the window then closes on its own. That door, opened by you and for a set time, is what tells a genuine history apart from a manufactured message.

The screen counts the messages coming in as they arrive, keeps the trail of every past window, and lets you close it early.

## 2. Create the password and do a dry run

Create an application password in **Mail software** ([how to](/en/suite/logiciel-de-messagerie.md)). The user name is the **address of the destination mailbox**.

Start with a folder survey, which writes nothing:

```
imapsync --dry --justfolders \

  --host1 imap.gmail.com --port1 993 --ssl1 --user1 you@gmail.com \

  --host2 imap.simafri.com --port2 993 --ssl2 --user2 you@yourdomain.tld
```

## 3. Map the folders

A Simafri Suite mailbox carries six folders: `INBOX`, `Sent`, `Drafts`, `Spam`, `Trash` and `Archive`. The mapping is declared explicitly, so that every message lands in the right place.

Two principles are enough to read the dry run's output:

* whatever really **files** mail at your provider gets a `--f1f2` onto one of the six;
* whatever is only a **second view** of the same mail stays aside. At Gmail, `All Mail`, `Starred` and `Important` are views: including them would bring every message in twice and file conversations where you are not expecting them.

Your source's drafts folder stays aside as well.

## 4. Run the migration

```
imapsync \

  --host1 imap.gmail.com --port1 993 --ssl1 --user1 you@gmail.com \

  --host2 imap.simafri.com --port2 993 --ssl2 --user2 you@yourdomain.tld \

  --exclude "^\[Gmail\]/All Mail$" --exclude "^\[Gmail\]/Drafts$" \

  --exclude "^\[Gmail\]/Starred$" --exclude "^\[Gmail\]/Important$" \

  --f1f2 "[Gmail]/Sent Mail=Sent" --f1f2 "[Gmail]/Trash=Trash" --f1f2 "[Gmail]/Spam=Spam"
```

**Budget the time from the number of messages, not from their weight**: around **0.8 messages per second**, whatever their size. A mailbox of 50,000 messages therefore takes on the order of seventeen hours, and you will reopen the window along the way.

**Stopping and running the same command again is expected**: what is already in is recognised and does not come in twice. The screen shows both numbers, messages that came in and messages already there.

If the account's plan is reached along the way, the migration stops there and says so. Move up a plan, run the same command again, and it picks up where it left off.

## What crosses over

|                                                        |                                                        |
| ------------------------------------------------------ | ------------------------------------------------------ |
| The whole message, headers, formatting and attachments | yes, to the byte                                       |
| The original arrival date                              | yes, and it is what sorts the thread                   |
| Read or unread                                         | yes, for the person running the migration              |
| The folder: inbox, sent, archive, trash, spam          | yes                                                    |
| Conversations                                          | rebuilt from the headers, as they are for today's mail |

Run the tool in its default order, oldest message first: that is how exchanges are put back together whole.

## Leaving with your mailbox

The same command, the other way round, takes your mail out to any IMAP provider. Nothing has to be opened or asked for: your application password is enough, and reading stays open whatever happens.

```
imapsync \

  --host1 imap.simafri.com --port1 993 --ssl1 --user1 you@yourdomain.tld \

  --host2 imap.other-provider.tld --port2 993 --ssl2 --user2 you@other-provider.tld
```

## A hand with it

Write to <support@simafri.com> with the name of your current provider and the rough size of the mailbox: we will help you with the folder mapping and the command to run.
