Python - imapclient - GMail
furas May 28th, 2018 363 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #! python3
- import imapclient
- import pyzmail
- imap = imapclient.IMAPClient('imap.gmail.com', use_uid=True)
- imap.login('your-login', 'your-password')
- #imap.select_folder('CRYPTO/trade', readonly=True)
- imap.select_folder('Inbox', readonly=True) # default folder with new messages
- unseen = imap.search(b'UNSEEN')
- for uid in unseen:
- print('uid:', uid)
- msg = imap.fetch([uid], [b'BODY', b'FLAGS'])
- trade = None
- message = pyzmail.PyzMessage.factory(msg[uid][b'BODY'])
- subject = message.get_subject()
- if 'strategy says sell now' in subject:
- print('sell signal found')
- trade = 'sell'
- elif 'strategy says buy now' in subject:
- print('buy signal found')
- trade = 'buy'
RAW Paste Data