diff options
Diffstat (limited to 'jobs')
-rwxr-xr-x | jobs/EmailChecker.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/jobs/EmailChecker.py b/jobs/EmailChecker.py index f65ed17..ee6db77 100755 --- a/jobs/EmailChecker.py +++ b/jobs/EmailChecker.py @@ -14,9 +14,12 @@ class EmailChecker(JobBase.JobBase): def execute(self): USER = self.config.get('email', 'user') PASS = self.config.get('email', 'pass') + + logdetails = "" #Generate a random subject subj = base64.b64encode(os.urandom(20)) + logdetails += "Target subject is " + subj + "\n\n" if not self.sendEmail(subj, "", USER): return False @@ -26,21 +29,26 @@ class EmailChecker(JobBase.JobBase): #If we have set up a filter to auto-delete messages from ourself if self.config.get('email', 'ideletesentmessagesautomatically'): + logdetails += "Switching to trash\n" M.select("[Gmail]/Trash") - criteria = '(FROM "'+USER+'" SINCE "'+datetime.date.today().strftime("%d-%b-%Y")+'")' + criteria = '(FROM "'+USER+'" SINCE "'+(datetime.date.today() - datetime.timedelta(hours=24)).strftime("%d-%b-%Y")+'")' + logdetails += "Criteria: " + criteria + "\n" typ, data = M.search(None, criteria) foundSubject = False for num in data[0].split(): + logdetails += "Found IMAP item" + str(num) + "\n" typ, data = M.fetch(num, '(BODY.PEEK[HEADER.FIELDS (Subject)])') + logdetails += "IMAP details: " + str(data) + "\n" if subj in data[0][1]: + logdetails += "Found the target subject!!\n" foundSubject = True M.close() M.logout() if not foundSubject: #This may not work, but try anyway - self.sendEmail("Email Fetch Failure", "") + self.sendEmail("Email Fetch Failure", logdetails) return False else: return True |