The topic mentioned in the title may seem outdated to respected Habr readers, but sometimes it's necessary to bring it up. The thing is, I've been working for many years as an administrator at a research institute focused on the humanities, where the staff's qualifications in modern information technologies are such that the infamous accounting department from IT jokes appears to be a gathering of philosophers, well-versed in all the mysteries of existence. Esteemed scholars manage to name email servers using Cyrillic letters, replace the “@” sign with the word “dog” in brackets (and then claim that is how it was written in the email address they received), attempt to send mail via WhatsApp using The Bat!, and do a host of other strange things, often in the same message. Teaching them is futile, fighting them is impossible; one must accept their fate and fully automate all operations related to correcting their mistakes.
One of the most sinister and dangerous operations in my experience has been migrating webmail from one server to another. The issue is that the institute's staff has three corporate email accounts: one includes an internal Exchange server, another operates on Mail.ru, and the third is on Gmail. No, I'm not the fool here, and neither are they. This is a directive from the management related to some departmental games. Some things must remain within the institute on the 'corporate' server, some, related to applications and grants, must go through Russian mail, and Gmail is connected to my esteemed colleagues for such undoubtedly essential things as Google Docs and Sheets, backup to their drives, etc. The problem is that, as we all know, too many cooks spoil the broth — in this case, among the three email servers, my colleagues manage to unambiguously lose the most important emails!
There is also another issue that often leads to the need for email migration. Modern email services frequently allow for automatic message forwarding from one server to another, meaning email collection. A user accustomed to having their messages from the Mail.ru server automatically copied to their Yandex account may eventually forget that, in this way, they are accessing only those messages received after setting up the email collection. This can naturally lead to a desire to fully migrate their email from the old server to the new one, which is often more frequently used. And where will they turn for help with this desire? Correct: to the nearest sysadmin!
I believe a similar situation arises for anyone who, for one reason or another, has to manage multiple email accounts, especially those who need to administer them or simply want to move from server to server without losing important information. Naturally, IT experts can solve this problem with a couple of clicks, but if you are inexperienced in such matters, migrating email can turn into a challenging task. That’s why I decided to briefly share my experience on how to export email to some storage smoothly and then import it to another server. Perhaps this operation will help someone avoid small inconveniences or simply make life easier!
Exporting Emails: A Bit of Theory, A Bit of Practice
Basically, mail servers work with client programs using one of two protocols: POP3 or IMAP. If these terms mean nothing to you, let me explain in simple terms: the POP3 protocol downloads emails from the server to your computer, while the IMAP protocol processes them directly on the server. Older mail clients by default worked (and continue to work) with the POP3 protocol, downloading email messages to a dedicated folder for the client (usually located somewhere in the user's directory, among hidden folders containing application data). The IMAP protocol is more modern, and it can also import emails to local or network storage. So the question mainly isn't about how to download the needed emails, but how to forward them to the right server to perform the mail migration. The simplest option is to use the IMAP protocol to copy all emails to some storage in EML format, and then upload them to another folder on a different account, taking advantage of the fact that the file format for emails is generally the same.
How to do this?
The simple method I use with the least effort is to migrate emails using some data copying software that supports the IMAP protocol. This is done in two steps.
- Importing mail from a folder on the server to some storage in EML format.
- Exporting email messages to another folder on a different server via IMAP.
In this case, the email migration program behaves like a standard IMAP client from the perspective of both servers. (By the way, most mail servers will require you to grant permission to use the specified program as a mail client, so before performing the mail migration with any utility, make sure to go to your mail account and allow the server to use this utility in the list of available clients via the IMAP protocol). Such programs usually require minimal manual work for pre-configuring email migration. You can often set even a schedule for regular automatic mail migration from server to server, if you need that. Personally, I use the program , fortunately, it runs on almost all our machines and requires minimal setup, which is centrally managed from the administrator's machine — there's no need to go anywhere. But, in the grand scheme of things, the software used isn't critical, as long as it can perform email export and import directly on Web servers, and supports a unified format for emails on both servers.
And Microsoft, as usual...
A separate headache is the migration of Exchange or Outlook email (I mean not the Outlook.com mail server, but the client), because Microsoft, as usual, takes an unconventional path. It's good if you have specialized software handy for exporting Outlook or Exchange server emails — then the task simplifies to just reading the migration instructions for emails managed by the appropriate program. Thankfully, there are quite a few such programs, as well as specialized plugins for the relevant software, geared towards Microsoft products.
Email migration via the POP3 protocol
Some enjoy the challenge, but generally speaking, it's not advisable. Therefore, don't transfer emails from server to server using the POP3 protocol; it's outdated and inelegant. Switch to IMAP on both servers (detailed instructions on how to do this are available from almost every provider), and then proceed as described above (or at least use the migration tool built into the email service — sometimes such tools are available, although their usability and operational logic often leaves much to be desired). You can also try the old-fashioned manual method: using a client program to move emails from folder to folder, or simply select them and send them to the new server. Back in the day, when we were younger, we all did it this way, and it didn't seem inappropriate to us, so in a desperate situation, it might be worth doing some of that manual work again...
Overall, migrating email from one server to another using the method of sequentially importing emails into storage and then exporting them to the new server via the IMAP protocol meets all the key criteria for the convenience of working with applications. These criteria include clear logic, security, automation, and the availability of numerous ready-to-use tools that can do this job for you. So, I hope this note is helpful to someone and simplifies life in cases when the accounting or planning department suddenly requires moving emails from Yandex to Mail.ru, from Google to Yahoo!, or anywhere else that a suddenly concerned manager orders. Don't let yourself be overwhelmed, colleagues!
Source: habr.com
