7

I have a website that I plan to give up, which is currently hosted by some company. I want to keep all my emails but they don't have an option for exporting emails.

How can I download all emails from all mailboxes, along with their attachments?

I don't want to be bound by one mail client. Super bonus points if each mail + attachments gets saved as a text file + attachment files in a seperate folder/archive so that I'm not bound by a specific mail client to read them.

I really prefer to use IMAP because if something gets screwed up the emails will still be there and I can try again.

2
  • Do you plan on migrating the e-mail somewhere else? In any case, the simplest thing to do is to connect a mail client to the service and download the messages or copy the messages to another server. Yes, it will be tied to a particular e-mail client, but who doesn't read e-mail in a mail client? How else do you plan to easily find e-mails? And if you transfer the e-mail to a different server you can use any client or webmail to access it. Some providers have a mail transfer capability where they can fetch the mail from a different server. For example, gmail easily does this. Jun 3, 2020 at 18:53
  • As a side note, you should consider detaching all of your email attachments if you haven't already - certainly anything that's important. It can reduce the size of your email by ~90% and will make it much easier to work with in these kinds of circumstances. Also, I recommend #1 in the answer below. Jun 4, 2020 at 11:26

1 Answer 1

6
+50

There are several methods to achieve what you want, and I'll try to show some of them.

Please note that some of the methods (if not all) involve working with email client software, but the decision which one to use is temporary, because you can later re-import the data or work with the data with any other email software I know about, or even without email clients at all.

In the following example, I use Thunderbird as IMAP and POP3 client because I know it better than Outlook and its colleagues.

Having said this:

1) Transfer to your own IMAP server

This is my favorite for such cases. I don't want my provider to keep messages anyway ...

So you could set up your own IMAP server. Depending on your needs, that could require knowledge (for example, setting up my favorite Cyrus Imapd under Linux) or could be very easy (for example, setting up hMailServer under Windows, which I also have running very reliably at one of my clients with 100 GB of messages, several hundreds of nested folders and more than 100.000 messages).

Then connect Thunderbird to your current server and to the new one which you just have set up, and simply copy all folders and messages from the old one to the new one. This can be a bit tedious, because Thunderbird sometimes refuses copying folder structures between different name spaces / servers, but if you don't have a lot of nested folders, it is the easiest method.

If you have a lot of nested folders, you might want to use Outlook for that part of the work. I have used it in former times, and as far as I can remember, it has no problems with recursively copying large folder structures. [Off-Topic: This is the one key point where Outlook is far superior than Thunderbird, but I'll stick with Thunderbird due to its other advantages].

If you don't want to use an email client, there are specialized scripts or command line tools out there; have a look for imapsync, for example. But be warned: They are much more difficult to use than common email clients.

When you have done this, you have copied all IMAP messages onto your own IMAP server which is completely under your own control, and you can connect with every email client software which is capable of IMAP to that server and work with your old messages.

2) Transfer into the "Local Folders" of Thunderbird

If you have ever used Thunderbird, you may have noticed that there is a section called "Local folders" in the account list. The folder structure and messages which are contained there are usually backed by files in the so-called mbox format. These files are usually located in the Thunderbird profile, which in turn is usually located in your Windows user profile directory.

So you could just connect Thunderbird to you current IMAP server and copy all folders and messages into the "Local Folders". Then you'll have that mbox files on your local disk which contain all folders and messages.

The mbox file format is understood by most other email clients I am aware of, so you can import these files into such clients.

Furthermore, mbox is text-oriented, so you can theoretically work directly with such files by opening them in a text editor. This is nice, but in practice does not lead anywhere, because you probably don't like needing to find the actual message text between HTML tags, or to decode attachments from base64 into pictures to view them, and so on. Plus, in mbox, all messages of a folder, including attachments, are stuffed into one big file.

It is convenient, though, if you like all your messages to be in one or more big mbox files which you can easily back up along with your user profile, and if you are ready to work with them using one of the many software clients which support it.

3) Synchronization and Offline Work

Each IMAP client I know (including Thunderbird) offers to synchronize IMAP messages to local disk, so that searching becomes faster and so that you can work with your messages even when you are disconnected from the IMAP server.

During synchronization, all folders and messages will be downloaded to your local disk, and you can normally work with them, even long after you have turned off your current IMAP server. There are pitfalls, though:

First, dependent on your software, you may have to tell the software which folders you want to work offline with. You have to be careful about that, because if you forget to include a folder there, the respective messages will be lost after you have turned off your current IMAP server.

Secondly, I have never tried and don't know what happens when you first let the messages synchronize with your current IMAP server, then work offline and turn that server off, and then reconnect the respective account to another IMAP server.

So if you decide to go that way, you should eventually make sure that the account which contains the synchronized message archive never gets connected to another IMAP server.

An additional disadvantage of that method is that the synchronized messages are not necessarily stored in a format which is understood by other email clients. I am really not sure, but I assume that you need the same client which has synchronized the messages to work with them.

I summary, I discourage that method.

4) Storing each message individually in the normal file system

There is a file format which is meant to store individual email messages; surprisingly, the file extension is .eml. You can easily "export" all messages from Thunderbird by just dragging them from the program window into arbitrary folders in the Windows file explorer. With Thunderbird, selecting multiple messages at once and dragging them into a folder works as expected - each message is turned into an individual .eml file.

To clarify, the .eml files are also text files (like the mbox files), so you can open them with any text editor. Like with the .mbox files, this is a bad idea (except for special purposes), because you eventually have to pick the actual message text from HTML documents, decode header lines if they contain special characters (like German umlauts), decode attachments and so on.

However, the .eml files always contain the complete message, including attachments and metadata.

Another good thing is that you can very easily re-import them into other email clients, at least in most of them: In case of Thunderbird, just drag them from the Windows file explorer into the program window, and they will become a normal message again, including attachments, and keeping all metadata information / headers (time received and so on).

Not every mail client may support direct drag-and-drop for .eml messages, but there is a vast number of plugins, scripts and helpers, e.g. for Outlook.

So if you really insist on keeping your email messages and attachments separately in a file system (which I personally would not do), that would be a possible way to go:

  • Connect Thunderbird to your current IMAP server
  • Recreate the IMAP folder structure in your Windows file system
  • Extract each attachment from each message and save it in the file system at the appropriate place; note that you can leave the attachment in the message or you can remove the attachment from the message when you do that
  • Select the message from Thunderbird's program window and drag it to the appropriate place in the Windows file explorer; dependent on how you did the previous step, that message will either still contain the attachments (you then have them twice, because you already have saved them separately) or not

Side note: In Thunderbird, you even can turn on saving each message in each account (synchronized IMAP, POP3, Local folder) directly as .eml, but I would strongly discourage you from doing so, because this is still somehow experimental.

For further information, consider this: https://support.mozilla.org/en-US/kb/maildir-thunderbird

5) Downloading via POP3

I understand your concern with that method, but it also has advantages. Personally, I prefer moving folders and messages instead of copying them, because when you copy several hundreds of thousands of messages which are nested many levels deep in thousands of folders, it is very difficult to verify that you indeed have copied all messages in all folders.

In contrast, when I move folders and messages, even when the process stalls, I can easily see whether I have lost something (in this case, it will still be on the old server) or not (in this case, no messages will be left on the old server).

Please note that the "number of messages" which most email clients show is not reliable, since you never can know how many messages (headers) the client has downloaded, especially when the respective folders have recently been filled at a high rate with messages, as happens when copying / moving. So you really should not use that "number of messages" to check whether your copy of the old server is complete.

Having said this, if you use Thunderbird to fetch messages via POP3 from your old server, these messages will also be backed by files which are located in the Thunderbird profile in your Windows user profile, so you could very well call this a complete download.

I am not sure about the format Thunderbird stores these messages in (it may be mbox either, but this is just an uneducated guess), so it could very well be that you can't import that archive into other email clients directly.

On the other hand, I am absolutely sure that there are a lot of utilities and converters which can import that POP3 archive into whatever other email software you want to use, Thunderbird itself being the primary choice among them: Nothing keeps you from copying or moving all messages from your POP3 account to another IMAP account, where you then can connect from any other IMAP-capable email client. Likewise, you can easily copy / move all messages from your POP3 account into the "Local Folders" section as described above, storing them in mbox format.

As a final word, there are several extensions for Thunderbird which deal with data export and import (including account information, messages and so on). However, I don't know them, so I can't tell how reliable they are. I have never used them because there are so many better methods to copy or move a mail archive.

I hope one of the methods shown above is appropriate for you ...

1
  • Thank you so much for your in-depth answer. This is just what I needed, bounty well deserved!
    – AnnoyinC
    Jun 4, 2020 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .