Delete mails from pop3 server using perl script

Posted on 2006-11-21
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

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 | 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?
Question by:riteshbawaskar
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 17

Accepted Solution

mjcoyne earned 50 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) {


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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

718 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