Author Topic: Empty trash older than...  (Read 13073 times)

Offline nurbles62

  • Newbie
  • *
  • Posts: 8
Empty trash older than...
« on: June 20, 2017, 10:00:18 AM »
It is great to have an option to empty trash automatically on logout.

It would be even greater if it were possible to to automatically empty trash older than a configurable time period on logout.  That way, one could still "trust" in the ability to recover items from trash, if necessary, for at least that time period.

Is there any chance that this is possible?

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Empty trash older than...
« Reply #1 on: June 20, 2017, 01:36:07 PM »
That is a job for the IMAP server. Delete trash messages older than x. That way it works regardless of if a user is connecting via Roundcube or not.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline nurbles62

  • Newbie
  • *
  • Posts: 8
Re: Empty trash older than...
« Reply #2 on: June 21, 2017, 03:09:03 PM »
First, I have looked at my mail directories on the server and found that I have three different trash folders.  One created when I was using Squirrelmail, of created when I replaced Squirrel with Roundcube, and the third created when I added my IMAP account to my android phone's mail client.  That pretty clearly indicates that the trash folders belong to the CLIENT rather than the server.

Second, I have been looking at RFC-3501 IMAPv4 to see what it says about the trash folder.  It says nothing.  The word trash does not occur in the RFC.  However, there IS a way (FLAGS) for an IMAP client to set (or clear) the /Deleted flag for any messages it desires and then to use EXPUNGE to actually remove any messages with the /Deleted flag set.  Since roundcube is able to format and display the dates in the messages, it seems like it should be possible for Roundcube to mark all messages older than X days for deletion when I ask to empty my trash.

I cannot find anything like that in the IMAP protocol, though individual IMAP server may implement extensions, I suppose.  But I don't think that Roundcube is trying to get locked in to a limited number of IMAP servers.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Empty trash older than...
« Reply #3 on: June 22, 2017, 02:08:12 AM »
You are correct this is nothing to do with IMAP itself. Perhaps I should have just said server rather than IMAP server but I didnt want you to think I meant the web server.

For example in my setup I use the SPECIAL-USE extension so the IMAP server can tell clients which folder is which, they all use the same folders for drafts, junk, and trash (or at least all clients that support speical use do) to save me configuring it each time. Then separatly I have cron task that deletes any message older than 30days from the junk or trash folders.

Some IMAP servers do have tools for jobs like this, for example, Doveadm-Expunge.

If you want a configurable per user solution that is configurable from Roundcube you are going to need some kind of plugin - either one that allows you to change settings stored on the server or one that actually does the work (again this would only work when you are logged in to roundcube)
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Re: Empty trash older than...
« Reply #4 on: June 22, 2017, 02:19:50 AM »
Cyrus IMAP for example has cyr_expire utility which can be controlled by users via IMAP using folder annotations.

Offline nurbles62

  • Newbie
  • *
  • Posts: 8
Re: Empty trash older than...
« Reply #5 on: June 22, 2017, 08:03:29 AM »
So are you saying that the general way that I outlined (using FLAGS to control /Deleted and EXPUNGE to remove deleted based on message dates) for Roundcube to add this feature, using parts of the IMAP protocol that all servers (should?) support either (a) will not work and/or (b) would be better implemented through the use custom plugins for each individual IMAP server on both the server *AND* Roundcube side of the connection?

If the FLAGS and EXPUNGE commands don't work as the RFC says they do (at least, when I read it), just let me know and I'll give up.  Also, if the developers just don't want to bother with this, fine, there's nothing I can do to change that.  But I'm having trouble understanding why/how it could be better to require many different pieces of code to handle the same feature due to each IMAP server's varying implementations of the extension to the IMAP protocol.

(Apologies... I'm not trying to be rude or argumentative, I'm honestly trying to understand your position.  Just for reference:  I've been a software developer professionally for over 30 years and started for fun ten years before that [yes, I started in 1977 -- really.] -- primarily DOS, then Windows, but also Linux and other systems and I also manage our (tiny) company's network servers and services [mail, www, ftp, etc.].  But I'm at a tiny company and wear [too] many hats, with Windows development being 90% of my work.)

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Empty trash older than...
« Reply #6 on: June 22, 2017, 09:56:54 AM »
You are correct in IMAP you can flag a message for deletion and then later call the expunge command to really delete those flagged messages. There is nothing automatic there though, the flag and expunge commands have to issed by the client.

As you might have found there are already settings in Roundcube for if messages should be flagged for deletion or just moved to the trash folder. Because different setups do it in different ways.

What I understand you are talking about is a special function which checks the date of message in specific folders and automatically deletes old ones. I doubt the devs would be interested in building something like that into the Roundcube core (though I cannot speak for them) because it is setup specific. Just like how the change password function cannot be built into the core, because the method needed to change a password is setup specifc.

Creating a Roundcube plugin that could do what you are asking would not be so hard I think but my point was not about the technical issue of doing it but about a more practical one that if you leave a function like this to the client then it only works when the client is running. Where as if the work is done by the server then it will always work no matter what client you are using.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline nurbles62

  • Newbie
  • *
  • Posts: 8
Re: Empty trash older than...
« Reply #7 on: June 22, 2017, 01:19:37 PM »
Quote
then it only works when the client is running
Actually, in my case that is exactly what I am asking for.  I really don't want some behind-the-scenes task deleting messages when I'm not around.

What I would love to have is something that is done ONLY when my email client (i.e. Roundcube, in this case) logs out.  That way, messages more than X days older than "now" (when I log out) will go away, but next time I log in, all of the others would still be there.  That way, if I go on vacation or worse, have an accident that keeps me away from my email, I don't need to worry that something I might need would be automatically removed while I'm gone.  Of course, it is MY responsibility to review my old trash the next time I log in or it would go away when I log out, but that is to be expected.

So the argument that it wouldn't happen when Roundcube isn't running is a PLUS in my opinion.

I probably interpret the Roundcube setting you mentioned, "Flag the message for deletion instead of delete," incorrectly.  To me it sounds like messages are marked for later deletion instead of immediately being deleted, but that does not appear to have anything to do with the trash folder.  Now, if the option said, "Mark messages as Trash instead of moving them immediately into the Trash folder" I would understand that option immediately.

Since FLAG, /Deleted, and EXPUNGE  work as I thought they did, it seems that all Roundcube would need to know is the name of your account's Trash folder (that may even be an existing Roundcube setting) in order to use a single function to use the advertised commands to implement the "delete trash older than" feature for ANY confirming IMAP server.

Oh well. Maybe someone who actually works on Roundcube will see this and let us know what they think about it.  Until then, I think I'm going to give up.

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Re: Empty trash older than...
« Reply #8 on: June 23, 2017, 02:07:01 AM »
There are pros and cons of such a feature. Imo the idea is not so bad. We have already a few feature request tickets about this and we didn't close them, which means we want that feature implemented. If you like to work on such a feature, we could provide you with hints about the implementation.

https://github.com/roundcube/roundcubemail/issues/5493
https://github.com/roundcube/roundcubemail/issues/5087
https://github.com/roundcube/roundcubemail/issues/5029

Offline ron4mac

  • Newbie
  • *
  • Posts: 2
Re: Empty trash older than...
« Reply #9 on: December 11, 2018, 01:25:09 PM »
I realize this is an old thread but I thought I'd resurrect it anyway.

I've written a plugin that will accomplish this sort of thing. It will delete messages prior to configurable timespans. There is a global timespan setting and each folder can have its own. It can be configured to perform the deletions at login, logout or just by use of a mail menubar icon.

It will mark for deletion or fully delete messages depending on the RC config setting. I can see from this thread that I need to add a folder override that will unconditionally fully delete messages from so-marked folders (as likely desired in the case of the Trash folder).

Those trying this plugin, please provide feedback here or at Github.

https://plugins.roundcube.net/packages/ron4mac/delete_old