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
Set quota and permissions for all email accounts based on the uid from the postfix.mailbox table
/scripts/cwp_api account mail_fix_permissions
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 ::
If the Password starts with:
$1$ then it is {MD5-CRYPT}
$5$ then it is {SHA256-CRYPT}
$6$ then it is {SHA512-CRYPT}
In this example we have $6$ ,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
example of $1$ md5
{MD5-CRYPT}$1$zSX9CTiE$q2fnbt8rqtYd/IOywZknE1
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"'
These instructions can be used for importing emails from any control panel, like cpanel, plesk or any other.
If you need to add multiple email accounts in the cwp you can do that by MySQL query for database postfix or by using API from cwp admin.
Email accounts are listed in the postfix.mailbox table.
Domains must be added to postfix.domain table.
Forwarders/Aliases are in the postfix.alias table.
The quota is in the postfix.quota2 table.
Autoresponders are in the postfix.vacation table.