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:
imap2imap.py
The configuration is fairly simple (and self explanatory):
imap2imap.conf
hostname=outlook.office365.com username=microsoftsucks@example.com password=hunter12 trash=Deleted Items #movetotrash=yes #delete=yes [destination] hostname=imap.gmail.com username=dontbeevil@gmail.com 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):
/etc/systemd/system/imap2imap.service
[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