#!/usr/bin/perl -w # Okay, nothin' fancy, just grab my mail and store it on disk: use Mail::POP3Client; use DateTime; use DateTime::Format::Mail; use File::Spec::Functions; my $basedir = '/home/jonadab/mail-proxy/store'; my $EOL = "\015\012"; my $pop = new Mail::POP3Client( USER => "jonadab", PASSWORD => "[secret]", HOST => "mail.bright.net" ); $pop->Connect(); my $cnt = $pop->Count(); if ($cnt) { print "The server has $cnt messages for me.\n"; my $now = DateTime->now(); my $nowdir = catfile($basedir, $now->ymd() . '_' . $now->hour() . $now->minute() . $now->second()); my $nowrcvd = DateTime::Format::Mail->new()->format_datetime($now); while (-e $nowdir) { my @c = qw(hai lou qan xi cho nau); $nowdir .= $c[rand @c]; } mkdir $nowdir; for my $num (1..$cnt) { print "."; print "\n" if not $cnt % 60; my $file = catfile($nowdir, $num); my $content = $pop->Retrieve($num); if ($content and (open MAIL, '>', $file)) { print MAIL "Received: from mail.bright.net by $0; $now$EOL"; print MAIL $content; close MAIL; $pop->Delete($num); } } $pop->Close(); }