Created
February 28, 2017 07:04
-
-
Save emrahgunduz/082c09b84145c7f021fe527f5d1120ac to your computer and use it in GitHub Desktop.
A bash script to clone multiple email-password combinations from one imap host to another. Requires imapsync installed/compiled and a csv file for email list. Uses port 993+ssl as default.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# CSV file line example: | |
# [email protected],PASSWORD | |
if [ -z "$1" ] | |
then | |
echo "CSV file is not specified!" | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then | |
echo "Missing host name (ex: imap.gmail.com or outlook.office365.com)" | |
exit 1 | |
fi | |
FILE=$1 | |
HOST=$2 | |
EMAIL=() | |
PASS=() | |
counter=0 | |
for line in `cat $FILE`; do | |
{ | |
EMAIL[counter]=`echo "$line" | cut -d, -f1` | |
PASS[counter]=`echo "$line" | cut -d, -f2` | |
((counter++)) | |
}; | |
done; | |
lastitem=$counter | |
counter=0 | |
function doOne { | |
if [ "$counter" -eq "$lastitem" ]; then | |
return | |
fi | |
E=${EMAIL[counter]} | |
P=${PASS[counter]} | |
imapsync --tmpdir /var/tmp --usecache --useuid \ | |
--host1 $HOST --user1 $E --password1 $P --port1 993 --ssl1 --authmech1 LOGIN \ | |
--host2 server.emrg.me --user2 $E --password2 $P --port2 993 --ssl2 & | |
((counter++)) | |
modulo=$((counter%5)) | |
if [ "$modulo" -eq "0" ]; then | |
wait | |
doOne | |
else | |
doOne | |
fi | |
} | |
doOne | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment