on to reading email in pythonthe script in example - employs python' standard poplib modulean implementation of the client-side interface to pop--the post office protocol pop is well-defined and widely available way to fetch email from servers over sockets this script connects to pop server to implement simple yet portable email download and display tool example - pp \internet\email\popmail py #!/usr/local/bin/python ""#############################################################################use the python pop mail interface module to view your pop email account messagesthis is just simple listing--see pymail py for client with more user interaction featuresand smtpmail py for script which sends mailpop is used to retrieve mailand runs on socket using port number on the server machinebut python' poplib hides all protocol detailsto send mailuse the smtplib module (or os popen('mail ')see alsoimaplib module for imap alternativepymailgui/pymailcgi for more features#############################################################################""import poplibgetpasssysmailconfig mailserver mailconfig popservername ex'pop rmi netmailuser mailconfig popusername ex'lutzmailpasswd getpass getpass('password for % ?mailserverprint('connecting 'server poplib pop (mailserverserver user(mailuserserver pass_(mailpasswdconnectlog in to mail server pass is reserved word tryprint(server getwelcome()print returned greeting message msgcountmsgbytes server stat(print('there are'msgcount'mail messages in'msgbytes'bytes'print(server list()print('- input('[press enter key]'for in range(msgcount)hdrmessageoctets server retr( + for line in messageprint(line decode()print('- if msgcount input('[press enter key]'finallyserver quit(print('bye 'octets is byte count retrieveprint all mail mail text is bytes in mail box locked till quit make sure we unlock mbox else locked till timeout popfetching email