Using poplib to parse headers
TheSaint
fc14301589 at icqmail.com
Tue May 27 04:21:01 EDT 2008
On 06:39, martedì 27 maggio 2008 Jean-Claude Neveu wrote:
> However, if I understand right, the Python poplib library will also
> parse the email for me so that I can iterate through the headers
See my program at http://it.geocities.com/call_me_not_now/index.html
You may study it.
But for short you can use
from email.Parser import HeaderParser
# then you can parse the mail, body etc here below
M = poplib.POP3('mail.blah.com')
M.user('username')
M.pass_('password')
numMsgs = len(M.list()[1])
for cnt in range(1, numMsgs +1):
header= M.top(cnt,0)[1])
HTH
More information about the Python-list
mailing list