-
Notifications
You must be signed in to change notification settings - Fork 0
/
imapsync.py
60 lines (52 loc) · 1.69 KB
/
imapsync.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
# Description : A python script that automates multiple email account transfers
# using the imapsync tool
# Usage : ./imapsync.py
#---------------------------------------------------------------------------------#
# Author : Florin Badea
# Source : https://github.com/flow0787/python-automation
#---------------------------------------------------------------------------------#
# Date : 03-09-2018
# Updated : 06-09-2018
# Requirements : python 2.7+ and imapsync
# References : N/A
#=================================================================================#
import subprocess
fromHost = raw_input("From Host: ")
toHost = raw_input("To Host: ")
emails = []
passwords = []
emailsToSync = {}
while (True):
email = raw_input("Email: ")
emails.append(email)
ass = raw_input("Pass: ")
passwords.append(ass)
emailsToSync = dict(zip(emails, passwords))
finished = raw_input("Finished? y/n ")
if finished.lower() == "y":
break
for emails, passwords in emailsToSync.items():
#if email1=email2 and pass1=pass2 run:
#os.system("imapsync --host1 %s --user1 %s --password1 '%s' --host2 %s --user2 %s --password2 '%s' --ssl1 --no-modulesversion --ssl2" % (fromHost, emails, passwords, toHost, emails, passwords))
args = [
"imapsync",
"--host1",
fromHost,
"--user1",
emails,
"--password1",
"'\"{}\"'".format(passwords),
"--host2",
toHost,
"--user2",
emails,
"--password2",
"'\"{}\"'".format(passwords),
"--ssl1",
"--no-modulesversion",
"--ssl2"
]
p = subprocess.Popen(args, stdout=subprocess.PIPE)
output, errors = p.communicate()
print(output)