{"id":180,"date":"2005-01-08T14:36:02","date_gmt":"2005-01-08T13:36:02","guid":{"rendered":"http:\/\/frenchfragfactory.net\/ozh\/archives\/2005\/01\/08\/deleting-all-mails-with-a-simple-perl-script\/"},"modified":"2007-05-09T23:39:28","modified_gmt":"2007-05-09T21:39:28","slug":"deleting-all-mails-with-a-simple-perl-script","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2005\/01\/deleting-all-mails-with-a-simple-perl-script\/","title":{"rendered":"Deleting all mails with a simple Perl script"},"content":{"rendered":"<p>I have a few alternative mail accounts, mostly used when I need to register with a site I don&#39;t trust and thus when I&#39;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 <a href=\"http:\/\/search.cpan.org\/~gbarr\/libnet-1.19\/Net\/POP3.pm\">Net::POP3<\/a>, to delete all mails in an account.<br \/>\n<!--more--><\/p>\n<div class=\"igsh-code-box\" id=\"ig-sh-1\"><pre class=\"language-perl line-numbers\" data-no-optimize=\"1\" data-cfasync=\"false\"><code class=\"language-perl\">#!\/usr\/bin\/perl\r\nuse Net::POP3;\r\nif (@ARGV &lt; 2) {\r\n\tprint &quot;Usage : $0 &lt;login&gt; &lt;pass&gt;\\n&quot;;\r\n\texit 0;\r\n}\r\n\r\nprint &quot;Going to delete ALL mail from account $ARGV[0] ! ctrl-c to abort\\n&quot;;\r\n\r\nsleep 3;\r\n$pop = Net::POP3-&gt;new(&#039;pop.free.fr&#039;);\r\ndie &quot;Couldn&#039;t log on to server&quot; unless $pop;\r\n\r\n$total = $pop-&gt;login($ARGV[0],$ARGV[1]);\r\ndie &quot;No mails or couldn&#039;t connect !&quot; unless $total;\r\n\r\nprint(&quot;Deleting $total mails ...\\n&quot;);\r\n\r\nfor($i = 0; $i&lt;$tot; $i++) {\r\n\t$pop-&gt;delete($i);\r\n}\r\n\r\n$pop-&gt;quit();\r\n\r\nexit 1;<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Spammed ? Delete all mails in a click !<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[2,9,27],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","tag-code","tag-perl","tag-spam"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}