If you are moving to Tygrys and you have an existing email account
You want to use Tygrys and you also want to keep all your emails from existing mailbox. Here is how to migrate your IMAP mailbox to Tygrys.
Mitigate privacy and security risk first
There are many online services available which allow you to migrate or backup your IMAP mailbox. However, the most significant problem with them is that you have to give up your login credentials to your mailbox and the entire mailbox transfer is executed by third party. This exposes your entire email communication to whoever handles the email migration.
This is not only a significant privacy risk but also a security risk. Often, some email messages contain information which can allow access to other services, link to private documents, and so on.
Therefore, I will be presenting you with a way to migrate your entire email account, which is not only private and secure but also completely free. The downside is that it requires some command line work.
Imapsync the best option so far
The Imapsync tool is the best option to migrate or copy emails between accounts I was able to find so far.
I have personally migrated several email accounts between different servers with great success.
The website provides all the details necessary. There is also an option to migrate mailbox using online service which is free with optional donation to the project. However, the online service requires providing login details to your mailbox and for privacy and security reasons; I am reluctant to do so.
However, the tool is quite simple to use from a command line on your own computer, and very effective, therefore, I still recommend sending the donation to support the project even if you do not use the online service to migrate the project.
Installation
Installation is documented in great details on the project website for every platform possible. Therefore, I am not copying this information here.
Take a look at the installation instructions and the author is very helpful if you get into problems.
Simple migration scripts
The Imapsync website contains tons of examples and explanation to every single option and combination. It also contains solutions to uncommon use-cases.
However, while using Imapsync I created 2 simple scripts which allow to easily migrate emails between 2 accounts. They work correctly, and can be run multiple times to resync mailboxes without ending up with duplicates.
Script for common mailboxes
This works for me when migrating emails between Tygrys accounts or Tygrys and accounts hosted on Mailu servers or IMAP servers running Dovecot as IMAP service. In other words, I use this script to migrate email between everything except Gmail accounts.
#!/bin/bash
SRC_HOST=source.mail.server
SRC_USER=source-email@address.com
SRC_PASS="your source password"
DEST_HOST=mx.your.tygrys.co
DEST_USER=dest-email@your-domain.com
DEST_PASS="your destination password"
# Sync any source mailbox with Tygrys as destination
./imapsync --host1 ${SRC_HOST} --user1 ${SRC_USER} --password1 "${SRC_PASS}" \
--host2 ${DEST_HOST} --user2 ${DEST_USER} --password2 "${DEST_PASS}" \
--ssl1 --ssl2 \
--maxbytespersecond 40_000 \
--maxbytesafter 3_000_000_000 \
--maxsleep 2 \
--maxsize 100000000 \
--skipcrossduplicates \
--regextrans2 's,:,-,g' \
--regextrans2 's,\s+(?=/|$),,g' \
--regextrans2 's,\",-,g' \
--regextrans2 's,&AAo-|&AA0ACg-|&AA0ACgANAAo-(?=/|$),,g'
# OPTIONALLY: Sync back, the destination with source.
# This is an optional step, if for some reason the destination mailbox contains messages
# which are not in the source mailbox and you need to keep both mailboxes in sync
# WARNING: Not recommended if both mailboxes are actively in use
./imapsync --host2 ${SRC_HOST} --user2 ${SRC_USER} --password2 "${SRC_PASS}" \
--host1 ${DEST_HOST} --user1 ${DEST_USER} --password1 "${DEST_PASS}" \
--ssl1 --ssl2 \
--maxbytespersecond 40_000 \
--maxbytesafter 3_000_000_000 \
--maxsleep 2 \
--maxsize 100000000 \
--skipcrossduplicates \
--regextrans2 's,:,-,g' \
--regextrans2 's,\s+(?=/|$),,g' \
--regextrans2 's,\",-,g' \
--regextrans2 's,&AAo-|&AA0ACg-|&AA0ACgANAAo-(?=/|$),,g'
Script to copy Gmail mailbox to Tygrys mailbox
The script is tested and works well while copying emails from GMail account to a Tygrys account.
#!/bin/bash
SRC_HOST=imap.gmail.com
SRC_USER=your-gmail-email@gmail.com
SRC_PASS="gmail password"
DEST_HOST=mx.your.tygrys.co
DEST_USER=dest-email@your-domain.com
DEST_PASS="your destination password"
# Sync source GMail mailbox with Tygrys mailbox as destination
./imapsync --host1 ${SRC_HOST} --user1 ${SRC_USER} --password1 "${SRC_PASS}" \
--host2 ${DEST_HOST} --user2 ${DEST_USER} --password2 "${DEST_PASS}" \
--ssl1 --nossl2 \
--maxbytespersecond 40_000 \
--maxbytesafter 3_000_000_000 \
--automap \
--maxsleep 2 \
--maxsize 10000000 \
--skipcrossduplicates \
--useheader="X-Gmail-Received" \
--useheader "Message-Id" \
--exclude '(?i)\b(Junk|Spam|Trash)\b' \
--regexflag 's/\\\\(?!Answered|Flagged|Deleted|Seen|Recent|Draft)[^\s]*\s*//ig' \
--regextrans2 's,:,-,g' \
--regextrans2 's,\",'\'',g' \
--regextrans2 's,\s+(?=/|$),,g' \
--regextrans2 's,\",-,g' \
--regextrans2 's,&AAo-|&AA0ACg-|&AA0ACgANAAo-(?=/|$),,g' \
--regextrans2 "s,\[Gmail\].,," \
--regextrans2 "s,\[Google Mail\].,," \
--folderlast "[Google Mail]/All Mail" \
--nofoldersizes --skipsize
I hope this helps. If you have any problems or questions, we are happy to answer any of them. However, for Imapsync specific questions, it is best to contact the author of the software.