I had a need for a simple IMAP to IMAP sync tool, yet the only useful things I could find were offlineimap and imapsync.
The offlineimap is too complex and does not exactly do what I want; while the latter went commercial and not is not a clean install (requires messing with CPAN/perl libraries).
How hard can it be to write one?
Here it is:
The configuration is fairly simple (and self explanatory):
hostname=outlook.office365.com email@example.com password=hunter12 trash=Deleted Items #movetotrash=yes #delete=yes [destination] hostname=imap.gmail.com firstname.lastname@example.org password=hunter12
Here how it works:
It logs in into both IMAP servers and basically copies (with optional source deletion) the messages across. It also avoids duplication by checking Message-ID header. It should be stable enough to “daemon”-ify.
Here is a systemd unit for it (if one wants it to run all the time):
[Unit] Description=IMAP to IMAP sync tool After=network.target [Service] Type=simple User=nobody WorkingDirectory=/usr/local/bin/ ExecStart=/usr/local/bin/imap2imap.py Restart=on-failure [Install] WantedBy=multi-user.target