In this step, I'm going to show you how to view a specific message + how to delete a specific message from the remote mailbox. Before I start my blah...blah..., I guess it will be good idea to give you a sample session using this step: POP server[192.168.1.1]: username at 192.168.1.1 [jchakma]: Enter password for jchakma@192.168.1.1: Ok, now trying to get connected to 192.168.1.1 .... Connected successfully to 192.168.1.1 Now trying to login... You got 3 mail(s) in 192.168.1.1 1 chakma junan Now, you can view/delete a message by typing: COMMAND> v2 # to view message number 2 COMMAND> d2 # to dele message number 2 COMMAND> s # to show all headers Ok, here comes some nasty subroutines to get my job done. showheaders subroutineThis subroutine simply shows all the headers in the remote mailbox --- if you are following all the previous steps, you need not go through this subroutine! It just greps all the headers and shows the From and Subject line. viewmessage subroutineThis subroutine simply retrieves a message from the remote mailserver and prints that message(including headers). This is more or less same as 'showheaders' subroutine. The important part is: $allmsg = $remoteserver->get($msg_no); foreach $line (@$allmsg) { print "$line"; } Since, get method returns a reference to an array, we access the contents of that array by '@$allmsg'. deletemessage subroutineThis subroutine simply marks a message for deletion --- it doesn't actually delete the message. The actual message deletion is done after you close your connection from the remote mail server. This subroutine also prompts you for reconfirmation. However, at the end of a session, the script again prompts for an updating-reconfirmation --- if you want to redo everything you done on a session, you can choose 'n' (meaning 'no') at the end of a session. An example session: You got 3 mail(s) in 192.168.1.1 1 chakma junan The next stepI haven't done anything on saving the mails retrieved from the remote mailserver --- all I did is to quickly view a summary of the remote mailbox. I hope to further develop this script so that you can as well save all the retrieved mails in your local mailbox(when? I'm not sure). Have fun. Bye! So, here goes the new code. Check it out! |
this page is maintained by:
jchakma@yahoo.com