Reading 'received' headers: Email Headers Parsing

Discussion in 'Python' started by dont bother, Mar 3, 2004.

  1. dont bother

    dont bother Guest

    Hi,
    I am a new bie experimenting with python.
    I have this piece of code to parse the received
    headers from emails. However, when I run with a file
    as an argument it skips lines like: 1, 3, 5 etc...
    I see why is this so : Its because of the
    msg=mbox.next()
    But I dont know how to fix this: I mean I dont know
    how I can stay at the current one and then when I am
    done with the current one I shall go to
    msg=mbox.next()

    Any hints?

    Thanks
    Dont











    import mailbox
    import string
    import email
    import email.Utils
    import time
    import sys
    import re

    #open passed mailbox filename
    fp=open(sys.argv[1], 'r')

    #open mailbox from file
    mbox=mailbox.PortableUnixMailbox(fp)

    #getcurrent time
    nowtime=time.time()

    #iterate over mail messages

    while 1:
    #get next message

    msg=mbox.next()


    #exit if we have looked at the last one

    if msg == None:
    break

    #get received header
    received =msg.get('received')
    print received
    #skup messages with no received header
    if received == None:
    continue



    __________________________________
    Do you Yahoo!?
    Yahoo! Search - Find what you’re looking for faster
    http://search.yahoo.com
     
    dont bother, Mar 3, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M Wells

    Processing a received email?

    M Wells, Jul 23, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,130
    M Wells
    Jul 23, 2003
  2. received your email

    , Aug 21, 2003, in forum: Python
    Replies:
    0
    Views:
    311
  3. Fortepianissimo

    module for parsing email Received headers?

    Fortepianissimo, Jan 10, 2004, in forum: Python
    Replies:
    1
    Views:
    412
    Skip Montanaro
    Jan 10, 2004
  4. Benjamin Han
    Replies:
    0
    Views:
    600
    Benjamin Han
    Jan 14, 2004
  5. David Karr
    Replies:
    2
    Views:
    135
    Bart Van der Donck
    May 6, 2009
Loading...

Share This Page