Solved Local archive of IMAP server

Greetings all,

is it possible to archive e-mail on a local machine, while leaving the e-mail on the remote IMAP server?

Kindest regards,

M
 
Sorry, I don’t know the exact answer. I don’t believe that this would work, and I never tried to work around for what IMAP is not designed to.

That said, this would be the typical POP3 scenario. So in your mail client, you would simply add a POP3 account in parallel to the IMAP one. Then adjust the POP3 account to NOT DELETE e-mails from the server. The IMAP account would continue to work as usual, and you could archive and re-organize the mails from the POP3 account without any fear to touch something on the server.
 
I have an rsync setup to run in cron twice daily to sync the directories over to a local system. Works fine for me.

Code:
0 */12 * * * /usr/local/bin/rsync -avz --del /var/mail/vhosts/ remote_box:/dump/mail_backup/vhosts
 
Hi,
Take a look at mail/isync
isync-1.3.3 Maintain local copies of remote IMAP folders w/synchronized flags
I am using it to transition from Thunderbird and to test a number of cli mail clients.

It is initially a little confusing as the command to run it is "mbsync" but there is as expected a good man page as well as
a "/usr/local/etc/mbsyncrc.sample"
https://kylebarbour.org/mimir/ has a useful 3-part article, simply ignore the irrelevant sections.
 
Hi obsigna,

thank you for your answer. I understand that IMAP is not designed for such a functionality. However, I need to have at least some e-mail messages saved long term, and clud provider is a single point of failure. Unfortunately, your suggestion did not work, I can select either IMAP or POP.

Hi RypPn,

thank you for your reply. Maybe I am misreading the functionality, but this will only synchronize the state of the server and local storage, correct? I want to keep at least some of the e-mail messages saved long term.

Hi bleedwood,

thank you for your reply. Just looking at themail/isync, it states: "isync is a command line application which synchronizes a local maildir-style mailbox with a remote IMAP4 mailbox." So, it again appears to be a synchronization only application. However, I will read the article, perhaps I am wrong.

Kindest regards,

M
 
Hi obsigna,

thank you for your answer. I understand that IMAP is not designed for such a functionality. However, I need to have at least some e-mail messages saved long term, and clud provider is a single point of failure. Unfortunately, your suggestion did not work, I can select either IMAP or POP.
If I add a new e-mail account in my e-mail client, I as well can select either IMAP or POP. So I select IMAP, and give that account the name Obsigna-IMAP. Then I add another account, where I again can select only IMAP or POP, and now I select POP and give that account, which btw. points to the same account on the mail server, the name Obsigna-POP.

Now you´re telling, that you can’t add a second account using POP when you had setup an IMAP one already. Who or what prohibits this? Perhaps it’s time to change the mail client?
 
Hi obsigna,

I think I misunderstood your suggestion. You are suggesting to not use the Web-based access, but use a stand-alone client with two accounts, one with IMAP server, the other with POP server. I wonder if this will work.

Kindest regards,

M
 
Hi Machiaveli,

thank you for the suggestion. No, I have not tried it. I am rather ignorant about the e-mail workings. However, recently I had been made aware of need to preserve some mail, so I started inquiring.

Just to make sure, it is retrieval not synchronization application, correct?

Kindest regards,

M
 
Hi obsigna,
I would like to give you some more details regarding my use case and I hope that it might give you some ideas.

I wanted to for a number of reasons stop using Thunderbird.
It was configured to use POP3 to collect my email from my domain which is hosted by an ISP and to store it locally in MH or mbox format.
I wanted to use a cli email client with notmuch to index and search my email so I wanted a local IMAP 'repository' using Maildir
so that I could test neomtt, aerc, and alot, none of which collect or fetch mail from an ISP, instead relying on something like isync for that functionality.
As this was a testing exercise I did not want to loose any email so I decided to temporarily continue using
Thunderbird as my client and to sync my email yet not delete new mail from the server for 'x' days.

What follows is not the most elegant approach - I disabled the POP3 collection in Thunderbird and created an IMAP account in Thunderbird temporarily disabling synchronization.
All my local folders within Thunderbird were then moved (drag 'n drop via Local Folders) from the POP3 account to the IMAP account which was then synchronized with my ISP.
My POP3 account and Local Folders copy in Thunderbird were deleted once I determined that my email had been successfully synchronized and that I had a working IMAP
setup.

isync is run on a manual basis synchronizing my new email to ~/mail, configured to only Pull new email and not to Expunge either Master or Slave.
I now have two copies of my email, the regular-use copy in ~/.thunderbird and my testing-copy in ~/mail which is synchronized when needed.
I hope this rambling assists you in finding an acceptable solution.
I will gladly give you more assistance and copies of my configs.

Have fun.
 
Hi bleedwood,

I take it that despite you addressing obsigna, your post is directed to me. Even if it is not, thank you for the detailed description and the offer to help.

As noted in my reply to Machiaveli, I have been just a naive user of e-mail via my e-mail provider web interface, so my knowledge in this topis is non-existent at worst to minimal as best, so I apologize for the potentially ignorant questions. Since I do have IMAP accounts to both of my providers, I can jump to your last paragraph. To simplify, let us consider only one of the IMAP accounts.

From what I understand, you suggest that I install Thunderbird. As I understand from reading https://support.mozilla.org/en-US/kb/imap-synchronization, I can then download to a local folder all the e-mail messages from all the folders at the host. Looking at your nomenclature, the e-mail will be in the ~/.thunderbird folder. So, even if the provider decides to lock or delete my account, I will always retain all the e-mail.

Could it be that the solution to my problem is so simple?

Could you please comment on the purpose of the ~/mail and the use of mail/isync specifically the configuration to "only Pull new email and not to Expunge either Master or Slave." I understand that it is for experimentation. But, why do you just not copy from the ~/.thunderbird folder?

Also, if I understand the configuration of mail/isync correctly, it will only add to the ~/mail, but not delete from it any messages that had been deleted from the server. If this is correct, is the step using Thunderbird necessary?

On a different note, how does one set the directory format to Maildir?

Kindest regards,

M
 
Hi mefizto,

Apologies for the mistaken addressing.

Firstly, you are correct, you do not need to use Thunderbird, it was merely used as an example of the steps that I took for my use case.
Thunderbird is however a simple and easy solution and you will have a local copy, just ensure that when you configure Thunderbird in
"Account Settings - Server Settings" you set "Server Type - IMAP Mail Server"

I would personally however suggest using the isync method, it does involve a little more effort but you will not have a
bloated application that will require regular updates .

You will find some documentation at :
or after installing isync, read the manpage and use the example file
/usr/local/etc/mbsyncrc.sample comment out everything that you will not use.

Apologies - the 'code' option will not co-operate, I guess that I need another coffee

mbsync only supports IMAP and Maildir

In ~/mbsync/.mbsyncrc you would configure some of the parameters that I mentioned e.g.

Expunge None # do not delete emails from Server i.e. Master or Local i.e. Slave
Create Both # create required folders on Master and Slave

MaildirStore local
Path ~/.mail/ # declare your chosen local disc path for saving data

IMAPStore [mefizto1] # example - useful for multiple accounts, you could also have mefizto2 ...
Host [where_to_fetch_mail] # supplied by your ISP
User [login_name_for_email_account]
Pass [xxxxx] # better to use supplied examples for something like gpg or Keyring

Channel mefisto1 # this and next 2 options used with IMAPSTORE for multiple accounts
Master :mefisto1:
Slave :local:mefisto1
Sync PullNew # only retrieve new mail

I hope that this is succinct.
Please ask should you need more clarity.
 
What you were going to do with the archive after it's archived? Might be helpful to decide which option to choose.
 
Hi bleedwood,

thank you very much for the detailed answer. I will then forego Thunderbird and work on the mail/isync. If I run into problems with the configuration, I will take an advantage of your offer to consultation.

Hi msplsh,

there are essentially tow classes of messages that I am concerned about.

The first one corresponds to topics that had been closed. These are true archives; thus, I am thinking of somehow preserving them for long term, e.g., calculating hash and storing them at several locations as they will not be updated.

The second class corresponds to topics that are still active. I am thinking about copying them to an additional location and running net/rsync only one way from the original download folder to the additional location, thus even if a mistake happens in the download folder, the additional location will always have all the history.

Does it make sense?

Hi Lamia,

the link does not work for me.

Kindest regards,

M
 
The first one corresponds to topics that had been closed. These are true archives; thus, I am thinking of somehow preserving them for long term, e.g., calculating hash and storing them at several locations as they will not be updated.

The second class corresponds to topics that are still active. I am thinking about copying them to an additional location and running net/rsync only one way from the original download folder to the additional location, thus even if a mistake happens in the download folder, the additional location will always have all the history.
Both requirements would be perfectly matched by mail/thunderbird (or any other mail client of your choice) in POP3 mode, and setting it up to leave the mails on the server. What again was your problem with POP3?
 
I suspect, you need fetchmail, not isync.

Both will download, but isync will also synchronize, what you delete on one end,
will be deleted on the other. That would not allow to build an archive.

But your mail client program should allow to save the mails you want to a file. Hence you do
not need anymore than a good mail client.
 
is it possible to archive e-mail on a local machine, while leaving the e-mail on the remote IMAP server?

Yes. If you need to archive all, use fetchmail, if you need to archive some you select, use your email client.

fetchmail will download the ones marked as new, and if you read it before from the server,
it will probably not download it. I never used it with imap, only with pop for reading email
from the local copy.

BTW. isync may be configured not to propagate deletion, but I am not sure it is the solution.
 
Hi obsigna,

I had never had a POP3 account for several reasons, instead relying on the convenience of accessing my e-mail from any computer from any location via the provided web interface.

Kindest regards,

M
 
Take a look at mail/isync
I am using it to transition from Thunderbird and to test a number of cli mail clients.

Excellent! Please, share your experience here:

 
thank you for another alternative.
If you use mail/alpine for reading (and writing) email, you save the whole message
you are reading to a local folder in directory ~/mail by pressing "s". Or only the
message to a file by pressing "e", but in the last case you mast press "v" to see a list of the
attachments and save each one to a file by pressing "s".

The last is what I do.
 
Hi obsigna,

I had never had a POP3 account for several reasons, instead relying on the convenience of accessing my e-mail from any computer from any location via the provided web interface.
Continue to use the web interface. You understand, what continue means, don’t you?
Then in addition utilize a traditional POP3 mail client for your offline archive and backup purposes. You understand, what in addition means, don’t you?
Anyway good luck, I won’t continue taking part in this discussion.
 
Back
Top