Aug-13-2018, 06:53 AM
Hello,
I've tried the code given below to read emails using poplib but I'm unable to get the output.
I've tried the code given below to read emails using poplib but I'm unable to get the output.
import poplib import string, random import io, email def readMail(): server = 'pop.gmail.com' user = 'user_email' password = 'password' srv = poplib.POP3_SSL(server) srv.user(user) srv.pass_(password) for i in range(0,5): id, size = string.split(items[i]) resp, text, octets = srv.retr(id) text = string.join(text,"\n") file = io.StringIO(text) message = email.Message(file) for k,v in message.items(): print(k, "=", v) readMail()