Skip to content

Instantly share code, notes, and snippets.

@fumionaito
Last active January 23, 2024 15:31
Show Gist options
  • Save fumionaito/98495b3ce5dfea1a2b58 to your computer and use it in GitHub Desktop.
Save fumionaito/98495b3ce5dfea1a2b58 to your computer and use it in GitHub Desktop.
Script to delete all mails on POP3 server.
#!/usr/bin/expect
set timeout 20
spawn telnet $env(POP3_SERVER) $env(POP3_PORT)
expect +OK; send "USER $env(POP3_USER)\r"
expect +OK; send "PASS $env(POP3_PASS)\r"
expect +OK; send "STAT\r"
set x 1
while { $x <= 10000 } {
expect +OK {
send "DELE $x\r"
incr x 1
} ERR {
send "QUIT\r"
exit
}
}
expect +OK; send "QUIT\r"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment