TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is There an IMAP2Git?

6 pointsby l0b0over 3 years ago
After using about half a dozen different email clients I don&#x27;t trust <i>any</i> of them to keep my messages safe indefinitely. I would much rather have several copies of every email all over the globe in a system which is fast and easy to sync, search, and reorganize, and which has easy recovery of deleted files: A self-hosted Git repository.<p>A quick search didn&#x27;t come up with any obvious candidates. There seems to be some projects out there for saving IMAP contents to various file formats, but none of the ones I found seem to have a big community, and I&#x27;ve no idea which file formats would be easily amenable to version control. Also, should I save the attachments embedded in the emails or as separate files (better version control and smaller email files, but breaks the explicit connection to the email file, and makes relocating them harder)? Finally, is there any reason why this is a terrible idea altogether, and I should just accept that personal messages from many years ago are just going to randomly disappear at some point?

4 comments

outsomniaover 3 years ago
How does your IMAP implmentation store the emails?<p>If it&#x27;s maildir format (it is for me on Postfix + Dovecot) you can just rsync the maildirs for users you care about, it also contains the IMAP folders and the original RFC822 emails.
评论 #29328992 未加载
seifferthover 3 years ago
While I don&#x27;t know of any imap to git sync tool specifically, there are tons of tools for storing email locally in plain text and for keeping these local email stores in sync with imap servers. The most common local email store formats seem to be mbox[1] and maildir[2]. Mbox stores one &quot;folder&quot; of emails per file, while maildir stores one email per file, which does seem to be the more modern approach (exceeding your file quota does not seem to be a particularly urgent problem anymore).<p>I personally use mbsync[3] to pull my email into a local maildir. I also use notmuch[4] and a nice tui[5] to search, read and write it. Note that filenames in maildir are unique, but provide little value beyond that. Some emails are also encoded in ways that will hide content from grep and friends (base64 being among the most popular ones). This makes notmuch especially valuable, as it abstracts all those encoding issues away and provides an amazing search interface.<p>I do not use a git repository for email myself, yet since a maildir is just a directory tree of plain text files, storing it in a repo is a no-brainer:<p><pre><code> mbsync -a # Configured via dotfiles cd my_local_maildir git add . git commit </code></pre> [1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Mbox" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Mbox</a><p>[2]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maildir" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Maildir</a><p>[3]: <a href="https:&#x2F;&#x2F;isync.sourceforge.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;isync.sourceforge.io&#x2F;</a><p>[4]: <a href="https:&#x2F;&#x2F;notmuchmail.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;notmuchmail.org&#x2F;</a><p>[5]: <a href="https:&#x2F;&#x2F;github.com&#x2F;wangp&#x2F;bower" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wangp&#x2F;bower</a>
评论 #29331550 未加载
jrootabegaover 3 years ago
What would a commit represent? I&#x27;ve been thinking idly about converting certain media to a vcs format myself.
评论 #29330116 未加载
nextosover 3 years ago
Have you looked into mbsync (isync) and notmuch?