http://www.perlmonks.org?node_id=21006
Category: E-Mail Programs
Author/Contact Info foo792@netzero.net
Description:
This perl script checks your e-mail account with the flags that you provide at the command line. NOTE: This perl script requires the Net::POP3 module. Get it from: http://www.cpan.org/modules/by-module/Net/libnet-1.0606.tar.gz. Example: pop_check <server_name> <account> <password>
#!/usr/bin/perl
use Net::POP3;
usage(0) if "-h" eq $ARGV[0]; || "-help" eq $ARGV[0];
usage(1) if 2 != $#ARGV;
($hostname, $account, $password) = @ARGV;
$handle = Net::POP3->new($hostname) or die "Unable to establish a POP3
+ connection to $hostname.\n";
defined($handle->login($account, $password)) or die "Unable to authent
+icate ($account, $password) at $hostname.\n";
$message_list = $handle->list or die "Unable to retreive list of avaib
+le mesages.\n";
foreach $item (keys %$message_list) {
$header = $handle->top($item);
print @$header;
}

sub usage {
print "Use this utility as 'pop_check HOSTNAME ACCOUNT PASSWORD',\n";
print " or 'pop_check -help', to see this message.\n";
exit($_[0]);
}
Replies are listed 'Best First'.
Re: pop3-check
by LupoX (Pilgrim) on Nov 20, 2001 at 19:39 UTC

    We startet a small project called "traymail" which is a mailclient for windows, featuring imap, POP3 AND security by ssl encryption. We had to take the uncool way using a tunnel programm called stunnel (www.stunnel.org)

    perhaps this is also usefull for your script since it sends plain passwords now.

    Take a look at our bullettin board for information about the traymail project.

    Have a good time...
    Georg (perlmonk@viot.de)
      pls send me the source code of outlook express if it is available..at aravind639@yahoo.com
Re: pop3-check
by khippy (Scribe) on Sep 18, 2001 at 12:34 UTC
    Hi Shotgun Bob,

    I have just read the code and I have found the line
    about list of messages. What do you think about
    enhancing your code to enable deleting unwanted
    messages at the mailserver (dele <msgnr>) directly to
    prevent you from downloading them?
    --
    there are no silly questions
    killerhippy
      I wrote a simple script that does essentially this. I even wrote a little scheduler for it as NT isn't as neat as *nix for scheduling. I felt very proud, then I discovered that Lincon Stein's book had pretty much the same thing in already, plus his was better.

      Have a look at his book, it's got a very good desciption of all things Net:: and CGI. Perl Network Programming

RE: pop3-check (is it secure?)
by ybiC (Prior) on Jul 05, 2000 at 08:20 UTC
    This looks like something I could use for one of my POP3 accounts that's otherwise inconvenient to access.

    Can senior Monks offer thoughts on viability or security of this little goody ?

    No offense intended here, Shotgun Bob. I'm just not terribly adept at OOP and have never delved into Net::POP3.
        cheers,
        ybiC