-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gmail_auto.py
61 lines (47 loc) · 1.55 KB
/
Gmail_auto.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
61
def check_user_and_continue():
data = open('data.txt','a+')
data.seek(0)
if(len(data.read())==0):
data.write(input("Enter username: ")+'\n')
data.write(input("Enter password: ")+'\n')
data.close()
else:
mainprog()
def mainprog():
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
data = open('data.txt','r')
uspass = data.readlines()
a = input("Enter email address(multiple separated by comma: ")
s = input("Enter subject: ")
t = input("Enter text: ")
browser = webdriver.Chrome()
browser.get('https://accounts.google.com/ServiceLogin/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=AddSession')
userid = browser.find_element_by_name("identifier")
userid.send_keys(uspass[0].rstrip())
userid.send_keys(u'\ue007')
time.sleep(2)
passw = browser.find_element_by_name("password")
passw.send_keys(uspass[1].rstrip())
passw.send_keys(u'\ue007')
time.sleep(10)
browser.get('https://mail.google.com/mail/u/0/#inbox?compose=new')
time.sleep(5)
to = browser.find_element_by_name("to")
to.send_keys(a)
to.send_keys(Keys.RETURN)
fr = browser.find_element_by_name("subjectbox")
fr.send_keys(s)
fr.send_keys(Keys.RETURN)
fr.send_keys(Keys.TAB)
x = browser.switch_to.active_element
time.sleep(1)
x.send_keys(t)
time.sleep(2)
x.send_keys(Keys.TAB)
z =browser.switch_to.active_element
z.click()
if(len(input("click return to exit"))>=0):
exit()
check_user_and_continue()