#!/usr/bin/perl -w use IO::Socket; use strict; my $EOL = "\015\012"; my $BLANK = $EOL x 1; my $username = "brice"; my $password = "mypassword"; my $count = 0; my @mailstat; my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "localhost", PeerPort => "pop3(110)", ) or die "cannot connect to daytime port at localhost"; $remote->autoflush(1); print $remote "USER $username" . $BLANK; print $remote "PASS $password" . $BLANK; print $remote "QUIT" . $BLANK; while ( <$remote> ) { if (/lock busy/) { die "Session already in use!\n"; } if (/OK $username has/) { @mailstat = split(/ /); } } if ($mailstat[3] eq "0") { print "You have no messages.\n"; } #### for ($count = $mailstat[3]; $count > 0; $count--) { print $remote "RETR $count" . $BLANK; #then do something with the data here. ???? }