def scrapeContacts(self):
if (not self.srv):
return
self.getMessages()
contacts = []
for (server_msg, body, octets) in self.msg_list:
mail = email.message_from_string('\n'.join(body))
for part in mail.walk():
fromaddr = part['from']
if (fromaddr):
sender = part['from'].split()[-1]
address = re.sub(r'[<>]','',sender)
# Ignore any occurences of own email address and add to list
if not re.search(r'' + re.escape(self.user),address) and not address in contacts:
contacts.append(address)
print "IDENTIFED new contact [%s]" % (address)
return contacts
评论列表
文章目录