Read this => How To Install Postfix Mail Server on Ubuntu

Step 1 – Install Imapsync

Imapsync package is available under EPEL package repository. First make sure you have added EPEL on your system or install it first. Now, install imapsync package using following command. At this stage, your system is ready for migration all data from one email account to other email accounts using IMAP.

Step 2 – Transfer Emails with IMAP

So you are ready for migration. Before migration make sure both accounts have IMAP running and accessible from your system. After that use following command syntax. The command will take a long time as per the size of your source Mailbox. After completing all process, you will see a long list of output. Check the output to find if any error occurred during transfer. Below is the small part of the result.

Read this => 5 Ways to Send Email From Linux Command Line

Reference:

https://imapsync.lamiral.info/ https://github.com/imapsync/imapsync