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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now