Review your favorite Linux distribution.
Go Back > Blogs > dr_agon
User Name


Rate this Entry

How to remove selected messages left on the POP3 server.

Posted 10-13-2008 at 05: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
The idea is simple:
  1. 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.
  2. pass the list of messages marked for deletion to the external program - This is done together with marking for removal. No additional action required.
  3. run external program to delete messages from the server - You can run it automatically if you wish.
To achieve this, I wrote two Perl scripts, and created a mail filter in Kmail.
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
    every message.
    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.

Posted in Uncategorized
Views 1607 Comments 0
« Prev     Main     Next »


All times are GMT -5. The time now is 01:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration