Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete mails from pop3 server using perl script

Posted on 2006-11-21
3
Medium Priority
?
1,000 Views
Last Modified: 2012-08-14
My pop3 sever does not support dele *.* to delete all the messages. I have to delete one by one. Also i am accessing the pop3 server using telnet.
How to delete all mails from the pop3 server using perl script
i am using script  as below

#!/usr/local/bin/perl
$username='username';
$password='password';
$MAX_MESS=$1;
sleep 1;
print  "USER $username \r\n";
sleep 1;
print  "PASS $password \r\n";
sleep 1;
for ($j = 1 ; $j<10;$j++)
{
        print "dele $j";
        sleep 1;      
}
sleep 1;

print "Quit";

and executing it as

deletemails.pl | telnet <ip of pop3 server> 110

the output of the above script does not seem to redirect to the telnet client. Is there any other way?
0
Comment
Question by:riteshbawaskar
3 Comments
 
LVL 17

Accepted Solution

by:
mjcoyne earned 200 total points
ID: 17986333
#!/usr/bin/perl -w
use strict;
use Net::POP3;

my $username = 'username';
my $password = 'password';

my $server = Net::POP3->new('pop3host', Timeout => 60);

if ($server->login($username, $password) > 0) {
  my $msgs = $server->list;
  foreach my $msg (keys %$msgs) {
    $server->delete($msg);
  }
}

$server->quit;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question