- while True:
- line = f.readline()
- if not line:
- break
- line = line.strip()
- if re.match('from:\s+', line, re.I):
- auth = __decode_header(re.findall('^.*?:\s+(.*)$', line)[0])
- authname, authemail = name_email(auth)
- elif re.match('date:\s+', line, re.I):
- authdate = re.findall('^.*?:\s+(.*)$', line)[0]
- elif re.match('subject:\s+', line, re.I):
- descr = __decode_header(re.findall('^.*?:\s+(.*)$', line)[0])
- elif line == '':
- # end of headers
- break
+ if msg.has_key('from'):
+ authname, authemail = name_email(__decode_header(msg['from']))
+ else:
+ authname = authemail = None
+
+ descr = __decode_header(msg['subject'])
+ authdate = msg['date']