How to remove selected messages left on the POP3 server.
Posted 10-13-2008 at 04:46 PM by dr_agon
applies to: KMail, Evolution, Perl, POP3, mail client
Unfortunatelly my favourite mail client (Kmail) cannot leave messages on the POP3 server while retrieving them and delete them later, eg. when they are moved to 'Trash" folder (like Thunderbird). The same applies to Evolution. Of course I know there are IMAP servers, but that's not the solution I like most. I also did not want to periodically erase all messages left on POP3 server. I did not find any reasonable solution, so I made it myself. It is available as DeleteFromPOP3 project at Sourceforge.net(tm).
The idea is simple:
- mark messages for deleting in the mail client - It is not so difficult to do it manually. I just delete mails from my inbox or mark them as spam. Then, from time to time I mark all files in the trash and spam folder for removal from POP3 server. When you create a mail filter and add it to the toolbar, it just requires one click to mark messages for removal.
- pass the list of messages marked for deletion to the external program - This is done together with marking for removal. No additional action required.
- run external program to delete messages from the server - You can run it automatically if you wish.
How it works
- A filter is invoked which executes a helper script passing the message as input.
- A message from mail client is parsed and information needed for
identification of message on the server is collected.
The script produces a pair of <host name> and <Message-Id> for
The pairs of <host name> and <Message-Id> are stored in
separate file, each in separate line
- The second script, which actually deletes messages from POP3
server, is executed whenever you like.
This script requires a list of messages created by previous
It also requires POP3 account details to connect to server(s).
After connecting to the POP3 server it looks through all
messages and checks if a message is on the list and should be
After deleting messages it truncates the message list file.
This may not be the best solution, but it works for me, and there is a good chance it will work for others, too. Any comments are welcomed.