Jump to Navigation

189 - Delete e-mail in an IMAP Server

If you want to delete a lot of e-mails in an IMAP server from Linux commnad line .
The following script would be useful.

* imap.sh

#!/bin/bash
openssl s_client -connect mail.myserver.com:993 -crlf -quiet < /root/scripts/imap.sct

* /root/scripts/imap.sct

? LOGIN oraprod oraflow
? SELECT "Trash"
? STORE 1:* +FLAGS (\Deleted)
? EXPUNGE
? SELECT "DISCARD"
? STORE 1:150 +FLAGS (\Deleted)
? EXPUNGE
? SELECT "PROCESS"
? STORE 1:2000 +FLAGS (\Deleted)
? EXPUNGE
? LOGOUT

 

Shell Script:


Main menu 2

Story | by Dr. Radut