imapsync and flags

imapsync is a imap copy / sync tool based on message-id headers. It doesn’t use any state file and therefore cannot do a real two-way sync, but for just copying from one to another server its a usefull tool.

The documentation states

“All flags are preserved, unread will stay unread, read will stay read, deleted will stay deleted.”.

Unfourtunately this is not true. Imapsync always adds flags, it never removes them. The issue can also be found in last version 1.285.

The absence of a flag is quite a worthwhile information, and when doing mirroring it is essentially. But the fix is easy: Just replace the single occurence of “+FLAGS” with “FLAG”, so that imap request results in not adding but replacing the flags on the destination server.