-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletespams.py
48 lines (32 loc) · 1.12 KB
/
deletespams.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
""" This file contains the main function for delete spams given a search
request and the folder to search
@author: Ahmed Tidiane BALDE
"""
from mail import connectImap, deletemails, listfolders, logout, searchmails
def main():
""" The possible folders are: (depending on your service provider)
You can select one of those to search emails from or delete emails
'INBOX'
'[Gmail]'
'[Gmail]/Brouillons'
'[Gmail]/Corbeille'
'[Gmail]/Important'
'[Gmail]/Messages envoyés'
'[Gmail]/Spam'
'[Gmail]/Suivis'
'[Gmail]/Tous les messages'
"""
email = input("Enter you email: ")
mdp = input("Enter your password: ")
imapObj = connectImap(email, mdp)
# print list of folders, might help if you do not have gmail like me
print(listfolders(imapObj))
# TODO, ask those filters on the terminal
uids = searchmails(imapObj,
'[Gmail]/Messages envoyés',
ON='17-Apr-2018',
FROM='baldeahmedtidiane36@gmail.com')
deletemails(imapObj, uids)
logout(imapObj, 'imap')
if __name__ == '__main__':
main()