1: <!-- Edit: 2001-03-03 by [neshura] moved to Craft since reformatting for snippets or catacombs requires moving bits and pieces into various fields not mapped here, but it is definitely a step up from Discussions -->
   2: 
   3: I am not exactly sure where to put this so I'll put it here...
   4: 
   5: <p><CODE>#!/usr/bin/perl -w
   6: 
   7: ###############################################################
   8: # Very, Very basic Pop3 mail reader written by 
   9: # David Middleton dmm@isp9.net
  10: # 10/19/00
  11: #
  12: # I wrote this because all the pop3 perl programs are 
  13: # either too lame for me to use or are too complex for
  14: # me to understand... All I want to do is make a simple
  15: # web based e-mail program. Is this too much to ask?
  16: #
  17: # Feel free to use, modify, distribute, laugh at...
  18: #
  19: # P.S. This requires the Pop3 perl module. 
  20: # If you don't have it, go to www.cpan.org
  21:  
  22: use Mail::POP3Client;
  23:  
  24: ################################################################
  25: # Grab user name, password and pop3 server from the command line
  26: # and log onto the mail server.
  27:  
  28: $user = $ARGV[0];
  29: $pass = $ARGV[1];
  30: $srvr = $ARGV[2];
  31:  
  32: $mail = new Mail::POP3Client($user, $pass, $srvr);
  33:  
  34: #####################################################
  35: # Make sure that everything is ok with the connection
  36:  
  37: $MailState = $mail->State;
  38:  
  39: if($MailState eq 'AUTHORIZATION') {
  40:  die "\n\nBad user name or password!\n" }
  41: elsif($MailState eq 'DEAD') {
  42:  die "\n\nMail server unreachable or unavailable!\n" }
  43:  
  44: ####################################
  45: # Print the # of messages then pause
  46:  
  47: print "You have ", $mail->Count, " new message(s).\n\n";
  48: print "Press any key to continue...\n\n";
  49: $anykey = <STDIN>;
  50: chomp $anykey;
  51:  
  52: ########################################
  53: # Read mail headers and get usefull info
  54:  
  55: for ($m = 1; $m<=$mail->Count; $m++) {
  56:   $Headers = $mail->Head($m);
  57:  
  58:  if($Headers =~ /(\bReturn-Path.*)/g){
  59:   $RTNP = $1}else{ $RTNP = 'Return-Path:'}
  60:  
  61:  if($Headers =~ /(\bDate.*)/g){
  62:   $Date = $1}else{ $Date = 'Date:'}
  63:  
  64:  if($Headers =~ /(\bFrom.*)/g){
  65:   $From = $1}else{$From = 'From:'}
  66:  
  67:  if($Headers =~ /(\bTo.*)/g){
  68:   $To = $1}else{ $To = 'To:'}
  69:  
  70:  if($Headers =~ /(\bSubject.*)/g){
  71:   $Subj = $1}else{ $Subj = 'Subject:'}
  72:  
  73: ###############
  74: # Now Print it
  75:   print "Message: ", $m, "\n", 
  76:    $Date,"\n",
  77:    $To,"\n",
  78:    $From,"\n", 
  79:    $RTNP, "\n",
  80:    $Subj,"\n\n"
  81: }
  82:  
  83: ##########################
  84: # Now look at a message...
  85: print "What message to you want to view? ";
  86: $i = <STDIN>;
  87: chomp $i;
  88:  
  89:      $Headers = $mail->Head($i);
  90:     @_ = split(/\n/, $Headers);
  91:             $Body = $mail->Body($i);
  92:  
  93:     print "\n\nMessage: ", $i, "\n\n";
  94:     print $Body;
  95: </CODE>
  96: <p><small>Edit: 2001-03-03 by [neshura] </small></p>

Replies are listed 'Best First'.
RE: Very simple POP3 mail reader
by dempa (Friar) on Oct 20, 2000 at 12:08 UTC
    Code is always appreciated, however...

    To quote the heading of the Monks Discussion page: This area is for discussion relating to this site. Have a look at this node and more specifically at the topic "Where do I post X?" for more info.

RE: Very simple POP3 mail reader (node approval, Editor requests)
by ybiC (Prior) on Oct 21, 2000 at 06:44 UTC
    Good point, dempa.

    Also, a friar or higher (who should know better) {grin} must have approved the node instead of moving it first.   But all is not lost.   Perhaps Cobra2411 might be persuaded to submit a petition to Editor requests to have it moved to Snippets or Code catacombs.
        cheers,
        Don
        striving for Perl Adept