47 lines
1.4 KiB
Bash
47 lines
1.4 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
move=false
|
||
|
|
||
|
if [[ ! -z $2 ]]; then
|
||
|
if [[ $2 == "move" ]]; then
|
||
|
move=true
|
||
|
elif [[ $2 == "sync" ]]; then
|
||
|
move=false
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
size=$( wc -l < $1 )
|
||
|
((size++))
|
||
|
temp=$( cat $1 | head -1 )
|
||
|
server=( $temp )
|
||
|
echo "From Server: ${server[0]}"
|
||
|
echo "Dest Server: ${server[1]}"
|
||
|
for ((pos=2; pos<$size; pos++))
|
||
|
do
|
||
|
temp=$( cat $1 | head -n $pos | tail -1 )
|
||
|
email=( $temp )
|
||
|
echo "Number: $((pos-1)) of $((size-2))"
|
||
|
echo "From Email: ${email[0]}"
|
||
|
echo "Password: ${email[1]}"
|
||
|
echo "To Email: ${email[2]}"
|
||
|
echo "Password: ${email[3]}"
|
||
|
echo "Number: $((pos-1)) of $((size-2))" > status.tmp
|
||
|
echo "Email: ${email[2]}" >> status.tmp
|
||
|
echo "Password: ${email[3]}" >> status.tmp
|
||
|
echo ""
|
||
|
if [[ $move == true ]]; then
|
||
|
echo "Moving mails..."
|
||
|
./imapsync --host1 "${server[0]}" --host2 "${server[1]}" --password1 "${email[1]}" --password2 "${email[3]}" --user1 "${email[0]}" --user2 "${email[2]}" --noemailreport1 --noemailreport2 --delete --noexpunge
|
||
|
elif [[ $move == false ]]; then
|
||
|
echo "Copying mails..."
|
||
|
./imapsync --host1 "${server[0]}" --host2 "${server[1]}" --password1 "${email[1]}" --password2 "${email[3]}" --user1 "${email[0]}" --user2 "${email[2]}" --noemailreport1 --noemailreport2 --nossl1 --nossl2 --notls1 --notls2
|
||
|
else
|
||
|
echo "ERROR"
|
||
|
exit 1
|
||
|
fi
|
||
|
echo ""
|
||
|
#wget -O mailsync.json "https://api.telegram.org/{putkeyhere}/sendMessage?chat_id={putchannelhere}&text=${email[2]}%20Synced!"
|
||
|
rm mailsync.json
|
||
|
done
|
||
|
rm status.tmp
|