IMAP: save messages locally when they get deleted from server

2

2

The scenario is:

  • an IMAP server with little space (say 1GB)
  • quite a few IMAP clients (say 2 phones, 1 tablet, 3 PCs) with an email client such as Thunderbird 38.3 or later

What I'd like to achieve is this:

  1. all PCs clients should keep a full copy (not just the header) of messages
  2. all PCs clients should save locally any message deleted remotely (i.e. move full message to a local folder before deleting it from its own IMAP folder, as a result of syncronization)

This way one could save space on IMAP server while keeping a local copy of all (full) messages on each PC (provided that PC clients are syncronized when an email is deleted from a non-PC client -- avoiding deletion from non-PC clients could be a workaround to ensure that local copies are complete).

I found some related questions that address similar scenarios (like this and this), but none gives a solution to this question.

I believe that this is quite a common need, so I hope that some email client guru, hopefully Thunderbird, come up with a solution.

mmj

Posted 2015-11-01T19:37:58.517

Reputation: 151

@emirjonb Don't think so, copying all messages from IMAP folder is not the point of my question. In my scenario the IMAP folder has little space, meaning that it can keep (say) few weeks of emails; that's why I need to create a local copy of emails when they are deleted from IMAP folder to make room. – mmj – 2015-11-03T12:08:41.610

ok than it is another option on configuring mail client that if you delete from server it won't delete the local mails. Or you can use POP3 on your clients in place of IMAP. POP3 by default download all emails and doesn't delete if the emails are deleted on server, so you can have all your mail locally and manually delete them if needed. – emirjonb – 2015-11-04T08:13:58.313

for the first solution link here: http://superuser.com/questions/369737/thunderbird-do-not-delete-local-copies-of-imap-messages

– emirjonb – 2015-11-04T08:26:16.980

@emirjonb I had seen that question/answer, but I could not make it work, because no filter was able to create a local copy of sent emails; the new (Thunderbird 38) "after sent" filter does not work, at least for me on a Gmail account). – mmj – 2015-11-04T08:51:44.537

I'd move on a larger server (like Gmail - no adv intended). You keep your existing address by forwarding from your current mailbox or by server to server POP3 retrieval (again, Gmail can do that in many cases). You can copy / move existing messages on the new account with Thunderbird (it may take a while, but you don't have to sit there while it's happening) – SΛLVΘ – 2015-11-04T18:16:28.327

Answers

1

You can create a Thunderbird filter which moves messages from IMAP folders to local folders.

Anyway an "IMAP archiver and deleter" appears to be a strong need of the Internet Community since at least 10 years, don't know why no solution came out till now. I am currently working at mine here:

https://jumpjack.wordpress.com/2016/03/10/come-cancellare-migliaia-di-email-dai-server-libero-in-un-colpo-solo/

My final objectives are:

1) set up an excel workbook which automates the task of deleting bunch of messages and/or donwload them.

2) Convert such workbook to a standalong VBS script for those who do not have MS Office installed.

3) Create a PHP page which performs such task for everybody, regardless of Windows/Mac/Linux

I am at good point for first, the others are still to come.

In the meantime, here they are some useful commands to manually play with you IMAP server:

Connect:

telnet imap.xxxx.yyyy  143 -f log.txt

Login:

. login user pass

List available folders:

. list "" *

Go inside a folder:

. select foldername

Mark messages from 1 to 15 as deleted:

. store 1:15 +FLAGS \Deleted

They will disappear in quite-real-time from Outlook.

Undo above (minus sign):

. store 1:15 -FLAGS \Deleted

(They will come back visible in Outlook).

Move such messages to trash folder (else they are just invisible, not deleted):

. move 1:15 trash

Actually delete the messages:

. select trash
. expunge

You can also past all commands into the telnet window to get them executed:

. select inbox
. store 1:15 +FLAGS \Deleted
. move 1:15 trash
. select trash
. expunge

To avoid "blind deletion" you need to know what's inside those messages from 1st to 15th.

. fetch 1:15 ( flags body[header.fields (subject date)])

jumpjack

Posted 2015-11-01T19:37:58.517

Reputation: 288

1

Until a better solution is found, I guess that the best workaround is to manually archive older messages when needed (e.g. when IMAP server quota limit is approaching). Of course you have to activate messages archiving to a local folder, for each IMAP account (this is necessary to make the "Archive" command button appear when you select messages).

I've also tried some add-on like Awesome Auto Archive and AutoarchiveReloaded, but both were unsatisfactory: the first gave me an error during configuration, the second is safer if run manually.

I hope some day Thunderbird will add a "simple" option for IMAP accounts able to automatically archive older messages when quota limit is approaching. I really wonder why such an important feature for IMAP accounts has not already been implemented.

mmj

Posted 2015-11-01T19:37:58.517

Reputation: 151

In Thunderbird you can create a local folder and a filter which moves all messages from an IMAP folder to a local folder. – jumpjack – 2017-08-16T16:32:09.607

0

Whenever my IMAP inbox gets almost full, I use "archive" operation in Thunderbird to manually move e-mails from IMAP folders to local folders that I keep in Dropbox folder.

So I keep up to 1 GB of important/recent mails on the IMAP server (so it is available on my phone) and all other archived (or copied) e-mails in local folders are synced between PCs over Dropbox and available to all PCs with Thunderbird installed (or you may use portable versions also). (If you change archived e-mail status or tag, that is also synced immediately to all other instances.) Dropbox also gives you at least 30 days of version history for all the files in case anything goes wrong.

But keep in mind that Thunderbird still has a nasty IMAP move/archive bug that can cause data loss if you do not do move operation while in off-line mode: https://bugzilla.mozilla.org/show_bug.cgi?id=462156

So you should copy/verify/delete manually instead of doing move/archive.

broslav

Posted 2015-11-01T19:37:58.517

Reputation: 101

0

You can use POP3 on your client's PC in place of IMAP or at least for one PC. POP3 by default download all emails and doesn't delete if the emails are deleted on server (doesn't do synchronization, only download email), so you can have all your mail downloaded locally and manually delete them if needed. here is the difference of this 2 protocols

Let the non-PC clients as IMAP because it is more handy with the synchronization and if some mails are deleted you can find them on the PC that uses POP3

emirjonb

Posted 2015-11-01T19:37:58.517

Reputation: 610

Are you sure that different email clients can use different protocol (IMAP or POP3) with the same email account/server? – mmj – 2015-11-04T08:39:14.073

Even if I asked for an IMAP solution, I guess POP3 with the "right" configuration (like "leave message on server for not more than 60 days" and, for phones and tablets, "download only header") could be an option, maybe the only option if IMAP management by Thunderbird is so inadequate (e.g. the new "after send" filtering option is not working for me). – mmj – 2015-11-04T08:45:52.207

Yes you can use different protocols for different mail-client, but remember if asked during configuration to always check to leave a copy on server – emirjonb – 2015-11-04T08:56:50.727

1Sorry but thinking back on my previous comment I must say that POP3 in NOT an option, because an email client cannot be aware of messsages sent by another email client, since sent messages cannot be uploaded to a POP3 server. – mmj – 2015-11-04T10:25:38.197