## Search for recent relevant messages search_term = "python" today = datetime.datetime.today() cutoff = today - datetime.timedelta(days=3) ## see http://tools.ietf.org/html/rfc3501#section-6.4.5 messages = server.search(['SINCE', cutoff.strftime('%d-%b-%Y'), u'TEXT', search_term],charset="UTF-8") #since is a special notification response = server.fetch(messages, ['RFC822']) for msgid, data in response.items(): # parsing and decoding msg_string = data[b'RFC822'].decode('utf-8') msg = email.message_from_string(msg_string, policy=email.policy.default) # extracting the right parts. print( msg['Date'], msg['From'],msg['Subject']) print(msg.get_body().get_payload()) """Twilio Set Up""" !pip install twilio # from https://www.twilio.com/docs/voice/tutorials/how-to-make-outbound-phone-calls-python from twilio.rest import Client from twilio.twiml.voice_response import Play, VoiceResponse twilioAccount = auth_pers['twilio']['accountSID'] twilioToken = auth_pers['twilio']['authToken'] twilioPhoneRobo = auth_pers['twilio']['phoneNumberTwilio'] twilioPhoneReal = auth_pers['twilio']['phoneNumberPersonal'] client = Client(twilioAccount, twilioToken)