imapsync

Installation #

source

First install access to the Epel repository via yum:

yum install epel-release

Then install imapsync and its dependencies:

yum install imapsync

After installing imapsync, it should be able to work on your system. A good test that shows also the basic example:

imapsync

A live test:

imapsync --testslive --tls1 --ssl2

Unit tests:

imapsync --tests

Unix Tutorial #

https://imapsync.lamiral.info/doc/TUTORIAL_Unix.html

Office 365 #

https://imapsync.lamiral.info/FAQ.d/FAQ.Office365.txt

Make sure IMAP is enabled. One way to test is using Thunderbird or some other email client.

It’s necessary to explicitly pass the --ssl1 flag in order to successfully connect to Office 365 for whatever reason.

For example:

root@vps72027 [/]# imapsync --host1 outlook.office365.com --ssl1 --port1 993 --user1 [email protected] --password1 'StarzR0ut#' --host2 $(hostname) --ssl2 --port2 993 --user2 [email protected] --password2 'StarzR0ut#' --timeout1 30 --justlogin

Reset passwords from file #

Designed to be able to be copy pasted into a terminal

read -p 'user: ' user
while read email pass; do
  uapi --output=jsonpretty \
  --user=$user \
  Email \
  passwd_pop \
  email="$email" \
  password="$pass"; 
done < users.txt

users.txt needs to be a file with space delimited username and password, one per line.

Create new email accounts #

Similar to above.

while read user domain password ; do uapi --user=davein5 Email add_pop email=$user password=$password quota=0 domain=$domain skip_upd ate_db=1 ; done < udp

Credit: David Bi.

imapsync all accounts from the “users” file #

users.txt needs to be a file with space delimited username and password, one per line.

Example users.txt:

[email protected] password123
[email protected] 123password
...

While loop:

read -p "Source host: " host1;
read -p "Destination host: " host2;
while read user pass; do
imapsync \
--host1 $host1 \
--user1 $user \
--password1 $pass \
--host2 $host2 \
--user2 $user \
--password2 $pass \
--justlogin;
done < users.txt

Note, this only works if the username and password are the same on both the source server and destination server.

Short version #

while read -r user pass; do imapsync --host1 imap.beget.com --user1 $user --password1 $pass --host2 secure.server.com --user2 $user --password2 $pass --justlogin; done < users | grep 'Authentication failed'