Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import imaplib
- import os
- import email
- import email.header
- from time import sleep
- while True:
- getmail = imaplib.IMAP4_SSL('imap.gmail.com','993')
- getmail.login('EMAIL','PASSWORD')
- getmail.select('Inbox')
- typ, data = getmail.search(None, 'ALL')
- if len(getmail.search(None, 'ALL')[1][0].split()) > 0:
- for num in data[0].split():
- typ, data = getmail.fetch(num, '(RFC822)')
- msg = email.message_from_string(data[0][1])
- if msg.get_content_maintype() == 'multipart':
- for part in msg.walk():
- if part.get_content_type() == "text/plain":
- content = part.get_payload(decode=True)
- else:
- content = msg.get_payload(decode=True)
- content = content.strip()
- decodesubj = email.header.decode_header(msg['Subject'])[0]
- subject = unicode(decodesubj[0])
- saycommand = 'aoss swift -n Callie "' + content + ' "'
- print saycommand
- if subject == "Say":
- os.system(saycommand)
- getmail.select('Inbox')
- typ, data = getmail.search(None, 'ALL')
- for num in data[0].split():
- getmail.store(num, '+FLAGS', '\\Deleted')
- getmail.expunge()
- getmail.close()
- getmail.logout()
- else:
- getmail.close()
- getmail.logout()
- sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement