Red Antigua Logo
Yet another piece of web.
Ads by Goooooogle
Search this site (by Google)
Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest 10 viruses - Sophos

Off topic    (top)
Personal home links

Mail::POP3Client Tutorial
Mail::POP3Client Tutorial
For this tutorial, you will need to have the Mail::POP3Client and the MD5 (as a depency) modules installed on your computer.
Download the modules from CPAN and install them.
You will also need a POP3 server account to test your code against.
For example, you can use Cucipop, available in FreeBSD as a port: /usr/ports/mail/cucipop

First, send some test mail to yourself.
If you want to send mail using Perl, check the Mail::Send tutorial.

With a local POP3 server, you can send yourself some test mail (type text written in bold):

    # mail kuuse@redantigua.com
    Subject: my 1st
    This is my 1st test.
    .
    EOT

Repeat with 2nd and 3rd. First check it manually:

    # mail
    Mail version 8.1 6/6/93. Type ? for help.
    "/var/mail/kuuse": 3 messages 3 new 3 unread
     N 1 kuuse Wed Sep 26 13:34 15/388 "my 1st"
     N 2 kuuse Wed Sep 26 13:38 14/359 "my 2nd"
     N 3 kuuse Wed Sep 26 13:38 14/358 "my 3rd"
    & x

Then create a Perl script called pop3.pl containing the following code:
use lib qw(/home/redanti/perl);
use strict;
use Mail::POP3Client;
my $pop = new Mail::POP3Client(
                               HOST => 'www.redantigua.com',
                               USER => 'kuuse',
                               PASSWORD => 'my_password',
                              );
$pop->Connect();
for( my $i = 1; $i <= $pop->Count(); $i++ ) {
  foreach( $pop->Head( $i ) ) {
    /^(From|Subject):\s+/i && print $_, "\n";
  }
}
$pop->Close();
and check your mail:

    # perl -w pop3.pl

Then output should look like this:

    From: Johan Kuuse <kuuse>
    Subject: my 1st
    From: Johan Kuuse <kuuse>
    Subject: my 2nd
    From: Johan Kuuse <kuuse>
    Subject: my 3rd

You will find more examples in the Mail::POP3Client documentation:

    # perldoc Mail::POP3Client

Last modified: Thu Aug 23 12:44:01 Romance Daylight Time 2007