syncIMAPMail utility |
syncIMAPMail is a program for copying e-mail folders with messages between accounts over IMAP.
It can be used for migration between servers, for creating copies of accounts within one server, and for other puroses.
The program copies "incrementally": it checks what messages already exist in the destination mailbox and copies only new messages from the source without creating duplicates, so you can apply the program to the same account multiple times. It is also faster than other copying utilities because it's multithreaded: it can read from the source mailbox and write to the destination in the same time, plus it can fetch multiple messages from the source in a single query and append multiple messages at a time if the destination server suports MULTIAPPEND IMAP extension.
Download syncIMAPMail
-
Operating System CPU Download Windows x86 Linux x86 x86-64 e2k FreeBSD 9+ x86 MacOS X x86 Sun Solaris Sparc
Only popular platforms are covered. The syncIMAPMail works over network, i.e. it doesn't have to be launched on the source or destination server machine (however doing so will make copying faster).
To contact authors please email to support@communigate.ru address.
Parameters
- syncIMAPMail [optional parameters] SrcServer[:port] srcUserName srcPassword DstServer[:port] dstUserName dstPassword
- SrcServer
- The hostname or IP address of the source IMAP server, with optional port number.
Note: the program doesn't support SSL/TLS. If it's required (e.g. with GMail which requires TLS to connect) - use stunnel software to create a proxy.
- srcUserName, srcPassword
- Strings to use when logging into the source IMAP server.
Note: the program uses only clear text password authentication, no SASL. If source and destination servers are not in the same network and "security" is required - create a VPN or use use stunnel.
- DstServer
- The hostname or IP address of the target IMAP server, with optional port number.
- dstUserName, dstPassword
- Strings to use when logging into the target IMAP server. Sample:
- --verbose
- Turns on verbose logging
- --logfile file.txt
- Redirects all logging output to the specified file.
Sample:./syncIMAPMail --verbose --logfile logs/$1.txt localhost:1143 $1 $2 imap.company.com $1 $2 - --list search
- The following search string is used to find
all mailboxes in the source account. Some IMAP servers show the entire user directory or even
system directory if the default search string "*" is used. Consult with your old IMAP
server manual to learn the search string to use.
Sample:./syncIMAPMail --list INBOX ...Copy INBOX mailbox only.
Sample:./syncIMAPMail --list "INBOX/*" ...Copy sub-mailboxes of INBOX mailbox, but not INBOX itself.
Note: here and everywhere else the mailbox names which contain non-ASCII characters should be specified "as is", in modified UTF-7 encoding.
Sample:./syncIMAPMail --list "&AMk-l&AOk-ments envoy&AOk-s" ...Copy "Éléments envoyés" mailbox. - --source prefix
- The following prefix string is used as the first
parameter of the "LIST" IMAP command. If the mailbox names produced with the LIST command
start with the specified prefix, the prefix is removed from the name when the mailbox is created on
the target server.
This feature allows you to copy a subtree of the source account mailbox tree into the "top" level of the target account mailbox tree. If the source account contains mailboxes abc/box1 and abc/box2, then --source abc/ parameter can be used to copy just these 2 mailboxes and to create them as "box1" and "box2" mailboxes in the root of the target account.
If the source server is CommuniGate Pro, this parameter can be used to copy all mailboxes from any account, using the postmaster name and password: --source '~username/'
See the --target option below. - --target prefix
- The following prefix string is appended to all
mailbox names sent to the target server. For example, if the target server is CommuniGate Pro,
you can specify the postmaster credentials in the parameters (instead of the dstUserName credentials),
and use the
--target '~username/'parameter to copy mailboxes to the username account. This can be useful when you do not know the username account password.
Sample:./syncIMAPMail --source ~user@company.com/ --target ~user@company.com/ 10.0.0.1 postmaster pass 10.0.0.2 postmaster passCopy mailboxes of user@company.com account using postmaster's credentials. - --skipMailbox mailboxName
- The specified mailboxName mailbox is not copied.
The mailboxName may contain wildcards (* and ?).
This parameter can be specified more than once, to exclude several mailboxes. - --renameMailbox oldMailboxName newMailboxName
- The oldMailboxName mailbox name in the source account is
automatically translated into newMailboxName name in the target account.
The oldMailboxName may contain wildcards (* and ?).
This parameter can be specified more than once, to rename several mailboxes. - --mode mode
- Sets the synchronization mode. The possible modes are:
- syncSrcAll
- Copies messages from source server which don't exist on target server.
This is the defauld mode. Use if for migration. - syncSrcNew
- Copies only messages which are newer than the most recent message on the target server.
The "--list INBOX" is automatically implied, but can be overriden.
Use this mode when user access mailboxes on target server but new messages still arrive to the source server. - syncDst
- Copies messages from source server which don't exist on target server.
Copies/synchronizes flags of existing messages.
Deletes messages on target server whcih don't exist on source server.
Deletes mailboxes (folders) on target server whcih don't exist on source server, unless --list option was used.
Deletes mailbox subscription on target server whcih don't exist on source server.
Use this mode when users access mailboxes on source server and the target server is used as a mirror.
- --notimeout
- The program increases the IMAP operation time-out value from 60 seconds to 1 hour. You may want to specify this option when your copy mail from slow servers.
- --noSubscription
- Turns off copying the mailbox subscription list to the target account.
- --noACL
- Turns off copying the mailbox ACL (access control lists) to the target account.
- --noSpecialUse
- Turns off copying the SPECIAL-USE attributes of mailboxes.
- --noForceIndex
- Turns off forcing the mailbox index creation. By default it forces index creation by setting and resetting a flag for the first message in a mailbox.
- --noNewUID
- Turns off using IMAP extension which suggests the target server the UID of a new message being appended.
Inportant: That extension works only with CommuniGate Pro 6.1.9 and later, so you MUST use --noNewUID if you're syncing to an older CommuniGate Pro version or to a third-party IMAP server. - --copyMailboxClass
- Can be specified if both source and target servers are CommuniGate Pro servers. When specified, the program copies the non-email mailbox classes ("calendar", "contacts", etc.)
- --proxyAuth username
- The 'PROXYAUTH username' command is used with the source IMAP server. Use this command to login to the source server as admin to retrieve mail from an account whose password you do not know, if your source server supports the PROXYAUTH IMAP command.
- --srcAuthPlain username
- --dstAuthPlain username
- The 'AUTHENICATE PLAIN' command is used with the source or destination IMAP server. Use this command to login to the server as admin to an account whose password you do not know, if your source/destination server supports the AUTHENICATE PLAIN command.
- --srcOAuth2
- The OAUTH2 authentication with the source IMAP server. The srcPassword parameter should be the name of a file which contains the access token.
- --fetchMax number
- Specifies the maximum number of messages which can be read from the source server in a single query. Default is 50.
- --fetchSizeMax number
- Specifies the maximum size of messages which can be read from the source server in a single query, in megabytes. Default is 10.
- --storeMax number
- Specifies the maximum number of messages which can be written to the target server in a single query. Default is 50.
- --storeSizeMax number
- Specifies the maximum size of messages which can be written to the target server in a single query, in megabytes. Default is 10.
- --queueMax number
- Specifies the maximum number of messages which can be kept in the program's internal queue. Default is 150.
- --queueSizeMax number
- Specifies the maximum size of messages in the program's internal queue, in megabytes. Default is 30.
You may lower the above values if the servers are slow or you're short in RAM. - --noThreads
- Turns off multithreaded mode.
You may want to specify this if your OS can't handle threads well.
Notes:
If a mailbox name in the source account starts with the symbol . or ~,
the mailbox name in the target account will start with the _ symbol.
Leading and trailing spaces, the \ and # symbols in the source account mailbox names
are replaced with the _ symbols.
The " symbols are replaced with the ' symbols.
If a mailbox name in the source account ends with symbols .mbox or .mdir or .mslc,
the mailbox name in the target account will end with the -mbox or -mdir or -mslc symbols.
Notes:
Messages with \Deleted flag are not copied.
If a message text doesn't end on EOL, it is automatically appended.
Message lines longer than 9000 bytes are automatically truncated.
Processing multiple Users
Assume that you have a users.txt tab-delimited text file that contains account names and passwords. You can automate launching the program repeatedly for eash user by using scripts.
- Example in Bash:
- #!/bin/bash inFile="users.txt" logDir="logs" if [ ! -d $logDir ]; then mkdir $logDir fi while read line do read user pass <<<$(IFS=$'\t'; echo $line) echo "Syncing '$user'" eval ./syncIMAPMail --logfile $logDir/$user.txt 10.10.10.10 $user $pass 127.0.0.1 $user $pass done < "$inFile"
- Example in Perl:
- #!/usr/bin/perl -w my $inFile="users.txt"; my $logDir="logs"; mkdir($logDir) unless(-d $logDir); open(F,$inFile) || die "can't open $inFile: $!"; while(<F>) { my($user,$pass)=split(/\s+/); print "Syncing '$user'\n"; system("./syncIMAPMail --logfile $logDir/$user.txt 10.10.10.10 $user $pass 127.0.0.1 $user $pass"); } close(F);
- Example of Windows BAT file:
- @echo off SET inFile=users.txt SET logDir=logs IF NOT EXIST %logDir% mkdir %logDir% FOR /F "tokens=1,2" %%i in (%inFile%) do ( echo Syncing '%%i' syncIMAPMail --logfile %logDir%/%%i.txt 10.10.10.10 %%i %%j 127.0.0.1 %%i %%j )