我正在尝试从我的 gmail 中的某个发件人那里下载所有电子邮件以进行分析。我在第 23 行遇到错误。
这是我的代码:
import imaplib
import email
mail = imaplib.IMAP4_SSL('imap.gmail.com')
username = raw_input('USERNAME (email):')
password = raw_input('PASSWORD: ')
try:
mail.login(username, password)
print "Logged in as %r !" % username
except imaplib.IMAP4.error:
print "Log in failed."
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.
fromWho = raw_input('FROM:')
result, data = mail.uid('search', None, '(FROM fromWho )') # search and return uids instead
latest_email_uid = data[0].split()[-1]
result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
raw_email = data[0][1]
这是我得到的错误:
Traceback (most recent call last):
File "test.py", line 23, in <module>
有什么想法吗??