Add mail-migration.sh

This commit is contained in:
Jay Booker 2025-07-02 06:40:45 +09:00
commit e39e08e080

33
mail-migration.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# Source and destination mail server setting
SERVER1=192.168.1.51
SERVER2=192.168.1.158
# Select appropriate auth mechanism.
#AUTHMECH1="--authmech1 LOGIN"
#AUTHMECH2="--authmech2 LOGIN"
# Uncomment if you want to start test/dryrun only. No emails will be transfered!
TESTONLY="--dry"
# Path to imapsync
imapsync=/opt/imapsync/imapsync
# Users file
if [ -z "$1" ]
then
echo "No users text file given."
exit
fi
if [ ! -f "$1" ]
then
echo "Given users text file \"$1\" does not exist"
exit
fi
# start loop
{ while IFS=';' read u1 p1 u2 p2; do
$imapsync ${TESTONLY} ${AUTHMECH1} --host1 ${SERVER1} --user1 "$u1" --password1 "$p1" ${AUTHMECH2} --host2 ${SERVER2} --user2 "$u2" --password2 "$p2"
done ; } < $1