My ISP provided me 5 free email ID, each with 1 GB size. However, one of the POP3 account has been spammed with over 2500+ spam messages. Getting those entire messages will not just waste my time but bandwidth too.
Sample shell script to delete all emails from POP3 server
So here is small shell script I wrote to get rid of all the messages on your POP server.
#!/bin/sh username="[email protected]"; password="mypop3server-password"; MAX_MESS=$1 [ $# -eq 0 ] && exit 1 || : sleep 2 echo USER $username sleep 1 echo PASS $password sleep 2 for (( j = 1 ; j <= $MAX_MESS; j++ )) do echo DELE $j sleep 1 done echo QUIT
First setup your POP3 username and password. Run this script as follows:
$ ./clean.pop3 2500 | telnet pop3.myisp.com 110
Trying 61.142.1xx.xxx... Connected to pop3.myisp.com.akadns.net. Escape character is '^]'. +OK hello from popgate(2.34.1) +OK password required. +OK maildrop ready, 2501 messages (40690358 octets) (40690358 2147483648) +OK message 1 marked deleted +OK message 2 marked deleted +OK message 3 marked deleted ....
- 2500: Total number of POP3 messages to remove
- telnet pop3.myisp.com 110: Telnet to ISP pop3 server and delete all emails from a POP3 server
If you are on dial-up internet connection this script is handy. If you prefer there is PHP version too .