From e39e08e080ae0868cb285b9aaf6798197c610637 Mon Sep 17 00:00:00 2001 From: jay Date: Wed, 2 Jul 2025 06:40:45 +0900 Subject: [PATCH] Add mail-migration.sh --- mail-migration.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 mail-migration.sh diff --git a/mail-migration.sh b/mail-migration.sh new file mode 100644 index 0000000..b2e19e3 --- /dev/null +++ b/mail-migration.sh @@ -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 \ No newline at end of file