2

Unfortuantely I lost mails on my Desktop and I'm now trying to restore them from my phone. k9-mail shows them all, but I can't find an mbox file or something similar to reimport them into Thundebird.

Does anyone know where exactly k9-mail stores its local mails?

  • Is your device rooted? If not, I'd try with an adb backup for the k9 package, and then analyze its contents. Mails are most likely stored within the app data directory, my guess would be a database. Cannot check currently, as I'm not at my desk. – Izzy Dec 19 '16 at 16:24
  • no its not rooted. it worked with adb backup, here's the description (just the first two steps to make it a .tar is enough): forum.xda-developers.com/showthread.php?t=2011811 they are not saved as simple mbox files though, it's a SQLite db – tonydo Dec 19 '16 at 17:10
  • So my guess was correct (and yes, I know that 2-step tar conversion, which is what I had in mind). So then it's a question now on how to extract your mails and convert them into a format Thunderbird can read. – Izzy Dec 19 '16 at 17:43
  • right. So make it an answer and I can mark this question as solved – tonydo Dec 20 '16 at 13:26
  • Isn't there a detail missing? I just explained where to find the mails, but not how to make them available in a "standard format". Missing the details for that :) Being at my desk again, I've checked with one of those databases – and couldn't see an easy approach, as a single message is split across multiple tables and columns. So I can put an answer to "where does k9 store its mails", but had to skip on "how to convert them to mbox". Would that be acceptable? – Izzy Dec 20 '16 at 23:47
1

K9 stores mails with its own app data, so you cannot access them without root except through the app. However, you can indirectly get hold on that creating an ADB backup (without password!) and converting that into a tar archive:

adb backup -f k9mail.ab com.fsck.k9
ab2tar k9mail.ab

ab2tar is a small helper script you can find in the tools/ directory of my little program Adebar (free, open-source; based on Bash and ADB). Alternative approaches for this conversion can also be found at XDA: What is an android adb backup?.

That done, extract the tarball and navigate into its apps/com.fsck.k9/db/ directory. Here you will find one or more .db files (one per mail account), which are SQLite files you can explore with apps like SQLiteman or SQLiteBrowser.

Mail headers and contents are spread across multiple tables and columns, so I cannot offer you an easy way to convert them into e.g. mbox format. On a "quick duck" (a search with DuckDuckGo) I found that question asked multiple times – but the closest and most precise answer was "you could to that in Python" (of course, without instructions). Still, as requested by you, the first steps as answer: At least you can browse your mails that way using a proper SQLite browser ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.