Print out email message from your email box : Email « Network « Python






Print out email message from your email box

 

import mailbox

mailboxname = "/tmp/mymailbox"
mbox = mailbox.UnixMailbox(open(mailboxname))

msgcounter = 0
while 1:
    mailmsg = mbox.next()
    if not mailmsg:
        break
    msgcounter = msgcounter + 1
    messagebody = mailmsg.fp.read()
    print messagebody
print
print "The message counter is %d" % (msgcounter)

   
  








Related examples in the same category

1.Send email to two receivers
2.Get email message mymailbox.msg file
3.Sending Some E-Mail
4.MIME Multipart Messages
5.Send an email
6.Login to POP3 server and retrieve information
7.Sending Mail over an SMTP Connection