Roundcube Trash Folder Fill Up

Anyone figured out the best way to get Roundcube to empty the trash folder when mail is deleted from external clients? I know there is Roundcube conf but editing many conf files is not the best approach with web control panels. Often systems like IW will overwrite manual changes. So this brings me to the forum.

Users are deleting mail using IMAP clients but in Roundcube that mail is just piling up in the Roundcube trash folder. I know Roundcube has the function to delete on logout but many accounts aren’t accessed via Roundcube but with external clients like Pegasus, Pop Peeper, Thunderbird, etc.


Hi cleverwise

I hope you don’t mind but I’ve thought about this, and thunderbird and Pegasus imap clients can be set to delete trash from server, or move trash to their local trash, I believe.

The other mail clients you mentioned I don’t know sorry.

I hope that helps a little

Many thanks


Thanks for the feedback John.

That doesn’t sit well with me. Relying on the client software to perform this function is silly. So I programmed a script that automatically flushes the Trash and Junk directory messages after x days. That is the only way to fly IMO.

I will release this script in the Hacks forum shortly.

The script, programmed in PHP, does the following:

  1. Dynamically queues all current domains to build a domain list.
  2. Using the domain list checks for all current email accounts.
  3. Deletes any messages in the Trash or Spam/Junk new and cur directories that are x days old.

The Trash and Junk mail days are separately configured. This way you can say set a shorter delay for Trash messages and longer for Junk. You simply crontab this PHP script and then your server will automatically flush old messages. Far better than relying on a client.

Hi Jeremy

Many thanks, and your script sounds lovely. Thank you for sharing it on the forums.

Our experience though is different, perhaps due to different client bases, and we used to do this when we first started, but due to client requests, we decided to stop it.

Many thanks


Sure. I had to do it for my company so I figured why not share it. :slight_smile:

I understand about your situation. I just don’t see the point in keeping something in Trash forever. Not that I am saying you have to use the script, obviously. However Trash and Junk days are configured separately.

So if you set Trash at say 30 or 60 days that is a long time to decide if something isn’t Trash. After all email doesn’t appear in Trash unless a user actually hits delete. As for Junk/SPAM the script doesn’t have a never delete, although it could be edited for that. However a day setting like 12000 is over 30 years, which is basically forever.

But, of course, you need to do what is right in your situation. :slight_smile:

Hi Jeremy

Haha, I remember the same situation over limits when outlook was designed, set at 2gb, which back then was thought to be never reached.

We have clients who use trash folder as a folder, lazy I know, but then they pay for the space and no amount of directly letting them know it was not designed for that purpose matters to them, but then thankfully, nearly all our clients use pop so our mailers are clear, or they have the options to upgrade to our enterprise mail clusters, which are dedicated.

Have a lovely night

Many thanks


Yeah clients are what they are. :slight_smile:

Not sure of your setup but if you have multiple environments perhaps you’ll find some use for this script. I admit my company isn’t hosting for others.

We are using IW (before cPanel) to help admin our own email. I don’t mind hand compiling Apache, OpenSSL, PHP, etc (actually provides more flexibility) but I can’t stand hand working with mail servers. I have done it in the past (Qmail, Postfix, etc) and it is a real pain to get everything working.

So for our setup IW is only handling our email side as our company’s sites are hosted on separate nodes with no control panels.

FYI I did edit the script to fix a bug and added in the ability to skip Trash or Junk processing. :slight_smile:

We have our’s set up to delete trash when you log out.

Roundcube -> Settings (Cog) -> Server Settings -> Maintenance

Clear Trash on logout [Ticked]
Compact Inbox on logout​ [Ticked]

Yeah that does work if you log into Roundcube. However if one uses external IMAP clients like Poppeeper, for example, and deletes mail it stays in Roundcube. So that option is great if you login in and out of Roundcube but not if other applications are used.