Instructions for manual import of the emails to your CWP server.

1. Create all required mailboxes via CWP
2. Login in each created mailbox (this will create required file and folder structure)
3. Copy the emails (like any other files) in /var/vmail/DOMAIN.COM/USERNAME
4. Fix Permissions (chown uploaded files vmail:mail)

Example path for email account: mark.s@cwp.com
/var/vmail/cwp.com/mark.s/

Example of rsync command from remote cPanel to local CWP:

rsync -avz -e "ssh -p 22" root@185.185.185.185:/home/USERNAME/mail/DOMAIN/USERNAME/ /var/vmail/DOMAIN/USERNAME/

** This command needs to be executed on the CWP server, number 22 is ssh port.

How to Fix Permissions
go to the folder where you have uploaded emails and execute the following command
chown vmail.mail *

Example:
cd /var/vmail/cwp.com/mark.s/cur
chown vmail.mail *

How to copy email account password from cpanel server

Location of email account password on cpanel server
/home/USERNAME/etc/DOMAIN/shadow

The password of an email account in cpanel looks like this:

$6$Tj4YOFiMG77ZE4rR$8Sf1fD/nve8ZoyMSF6JXcYW7uMuPig3PO58IYxL6OGuoxrfVBLaBztQ63RhGmxUeaWbjexiENRbyH7zW5v9ZB5

* We only need the part between two colon ::

Edit password in the database and add this in front of it: {SHA512-CRYPT}

In the database, it would look like this

{SHA512-CRYPT}$6$Tj4YOFiMG77ZE4rR$8Sf1fD/nve8ZoyMSF6JXcYW7uMuPig3PO58IYxL6OGuoxrfVBLaBztQ63RhGmxUeaWbjexiENRbyH7zW5v9ZB5

So how to do it? go in cwp and create an email account with the random password and then edit it via phpMyAdmin or from the bash.
Password is stored in the database: postfix, table: mailbox, column name: password

Update code from bash would look like this:

mysql postfix -e 'UPDATE mailbox SET password = "{SHA512-CRYPT}$6$Tj4YOFiMG77ZE4rR$8Sf1fD/nve8ZoyMSF6JXcYW7uMuPig3PO58IYxL6OGuoxrfVBLaBztQ63RhGmxUeaWbjexiENRbyH7zW5v9ZB5" WHERE username = "test@domain.com"'

This instructions can be used for importing emails from any control panel, like cpanel, plesk or any other.