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