-
Notifications
You must be signed in to change notification settings - Fork 0
/
client-asshole.py
68 lines (57 loc) · 2.16 KB
/
client-asshole.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
62
63
64
65
66
67
68
#! /usr/bin/env python3
#Author : Aravind
# platform tested : windows and linux
# Python 3.7+
# Created on 08/01/2022
# email client
import imaplib
import email
from clientfuckedupagain.mailclient import sendmail
from clientfuckedupagain.pramikobaby import sshconnection
import schedule
import time
def incommingmail():
# credentials
username = "xxxxxx@gmail.com" # your email
# app password
app_password = "xxxxxxx" # password
# For more >> https://www.systoolsgroup.com/imap/
gmail_host = 'imap.gmail.com' # gmail host
# set connection
mail = imaplib.IMAP4_SSL(gmail_host)
# login
log = mail.login(username, app_password)
print(log)
# select inbox
mail.select("INBOX")
n = 0
# select specific mails from specific user
# reads unread email from specified email id(say clients)
retcode, selected_mails = mail.search(
None, '(UNSEEN)', '(FROM "xxxxxxx.com")')
if retcode == 'OK':
for num in selected_mails[0].split():
# print(num)
print('Processing ')
n = n+1
typ, data = mail.fetch(num, '(RFC822)')
for response_part in data:
if isinstance(response_part, tuple):
original = email.message_from_bytes(data[0][1])
print(original['From'])
Subject = (original['Subject'])
for part in original.walk():
if part.get_content_type() == "text/plain" or part.get_content_type() == "text/html":
message = part.get_payload(decode=True)
m = (message.decode())
if (Subject.find(('help') or ('trouble') or ('sorry')) != -1) or (m.find(('help') or ('trouble') or ('sorry')) != -1):
sshconnection()
sendmail()
typ, data = mail.store(num, '+FLAGS', '\\Seen')
else:
typ, data = mail.store(num, '-FLAGS', '\\Seen')
# check for incomming email every 10 minutes
schedule.every(10).minutes.do(incommingmail)
while True:
schedule.run_pending()
time.sleep(1)