How to remove selected messages left on the POP3 server.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By dr_agon at 2008-10-13 16:46
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.
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
script.
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
deleted.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.