In: , ,
On: 2005 / 01 / 08 Viewed: 29275 times

I have a few alternative mail accounts, mostly used when I need to register with a site I don't trust and thus when I'm expecting spam. Checking last night, I noticed that 3 accounts were filled up with a grand total of 3500 spams, so I wrote a small Perl script, using Net::POP3, to delete all mails in an account.

PERL:
  1. #!/usr/bin/perl
  2. use Net::POP3;
  3. if (@ARGV <2) {
  4.     print "Usage : $0 <login> <pass>\n";
  5.     exit 0;
  6. }
  7.  
  8. print "Going to delete ALL mail from account $ARGV[0] ! ctrl-c to abort\n";
  9.  
  10. sleep 3;
  11. $pop = Net::POP3->new('pop.free.fr');
  12. die "Couldn’t log on to server" unless $pop;
  13.  
  14. $total = $pop->login($ARGV[0],$ARGV[1]);
  15. die "No mails or couldn’t connect !" unless $total;
  16.  
  17. print("Deleting $total mails ...\n");
  18.  
  19. for($i = 0; $i<$tot; $i++) {
  20.     $pop->delete($i);
  21. }
  22.  
  23. $pop->quit();
  24.  
  25. exit 1;

Related posts

Metastuff

This entry "Deleting all mails with a simple Perl script" was posted on 08/01/2005 at 2:36 pm and is tagged with , ,
Watch this discussion : Comments RSS 2.0. You can trackback this post from your own site

4 Blablas

  1. 1
    dju` France »
    said, on 08/Jan/05 at 6:16 pm # :

    cool. perhaps adding the POP server as a third argument would be a good idea...

  2. 2
    ralf Germany »
    commented, on 21/Feb/05 at 10:53 pm # :

    Nice script, but has a little error:
    for($i = 0; $i

  3. 3
    Ozh France »
    thought, on 21/Feb/05 at 11:44 pm # :

    Hmm, what is the error then ? Works fine for me :)

  4. 4
    Brian United States »
    replied, on 04/Jul/06 at 6:01 am # :

    The error is that the for loop variable is "$tot" where it should be "$total"

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Read more ?

Close
E-mail It