Operating System - Linux
1751936 Members
4732 Online
108783 Solutions
New Discussion юеВ

Re: Perl Scripting for mail handling

 
SOLVED
Go to solution
Henry Chua
Super Advisor

Perl Scripting for mail handling

Hi guys,

I am relatively new to perl, am trying to write some stuff... can someone roughly explain each line do?:

#!/usr/bin/perl

use strict;
use Mail::POP3Client;

#---------------------------------------------------------
#
#
sub clear_mail
{
my $pop;
my $n;
my $i;
my $test_text;
my $user;
my $passwd;
my $server;

$server = $_[0];
$user = $_[1];
$passwd = $_[2];
$pop = new Mail::POP3Client(
USER => $user,
PASSWORD => $passwd,
HOST => $server,
AUTH_MODE => "PASS",
DEBUG => 0
);
$i = 1;
$n = $pop->Count();
print STDERR "Clearing $n old messages on server...\n";

for ( $i = 1 ; $i <= $n ; $i++ )
{
print STDERR "------ Message $i\n";
print STDERR $pop->Body($i);
print STDERR "\n-----------------------\n";
$pop->Delete($i);
}
print STDERR "Old messages cleared.\n";
return ($n);
}

#---------------------------------------------------------

clear_mail( $ARGV[0], $ARGV[1], $ARGV[2] );


I know it is to remove the mail from the argurement defined account, but dunno the code in specific.. how can i insert lines to append all the mails to a log.. say "/tmp/log.txt".

Thanks!
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Perl Scripting for mail handling

Can you tell me what

# man Mail::POP3Client

or

# perldoc Mail::POP3Client

is not explaining enough? Explaining each line is a bit dumb imho.

# man perltoc

will give you the content list of what on-line documentation is available

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Henry Chua
Super Advisor

Re: Perl Scripting for mail handling

Hi Merijn,

Thanks figure it out..

Regards
Henry