download Dovecot emails over rsync (done!), possible alternatives

Carles Pina i Estany carles at pina.cat
Sun Jan 27 03:22:28 EET 2019


Hello,

Apologies for the extra long email. It's a situation with a solved
problem and I might need to solve it again, I'd like to have some
feedback.

Two years ago, in a trip around the Antarctic with a very limited
communication I deployed a mail system based on Postfix+Dovecot.  I need
to do something similar again and I used a "hack" that I thought that I
might avoid (that time, let's say, everything was last minute... or
later than last minute!).

I installed Dovecot on the internet server and the server on the ship.

On the ship I had a fetchmail downloading "small emails" (up to 100 KB
if I remember correctly) and delivering to the local server. For bigger
emails fetchmail had a "size limit" and fetchmail was not downloading
them. I wrote a Python script that was connecting from the ship, to the
internet server, and was listing the emails that were "too big to be
downloaded" (this was for each user. I could have done something
different with procmailrc I think on the receiving time).

The Python script was fetching, if I remember correctly, the email ID,
date, subject and size. The Python script was sending an email to the
ship server's user saying "there is an email for you with this size,
from, date and subject and this is the email ID" (and inserting this
into a database to avoid sending the same notification to the users
again).

Then the scientists sometimes were ignoring the email, were asking to
the sender to send a smaller version, or asking me to download it when
possible.

If they wanted me to download the email:

I had a script that was connecting to the internet server, opening
/home/$USER/Maildir/dovecot-uidlist, finding the file for that email
UUID (this was a simple script on the internet server and I was
executing it using ssh and getting the output). Then it was creating a
new IMAP folder named "Downloaded" in the ship's server (it was just
creating the folder in the file system and adding it in the
subscriptions file, all using file system operations from Python). Then
using rsync it was downloading the email file from the internet's server
to the ship's server temporary file (taking whatever it would take, with
many retries, etc.) and then moving it to the Downloaded folder.

(note: it was using rsync and not IMAP because the connection was slow
and very unstable. With rsync and the correct options it was continuing
the download and retrying until success).

For the next expedition I'll have more time to prepare for a similar
setup. I've considered if I should stop relying on dovecot-uidlist,
local file system's, subscriptions, etc. and if I should write a plugin
for Dovecot to expose part of this information using... a JSON API? IMAP
commands?

The local ship's server bit: could I inject a SMTP mail file
(downloaded) using Dovecot admin commands? some API? Any advantage?

To discover which file to download using rsync: instead of opening the
dovecot-uidlist any better method?

Any other different approach that I might want to consider?

Sorry again for the long message. I thought that this might need some
context. Also, thanks to the design of Dovecot I could do what I did
in a very simple way. Actually Dovecot design was as I would have
designed for this use case (the index file, subscription from the
mailing list, etc.).

Thank you very much again! and thanks for the great Dovecot as well!

-- 
Carles Pina i Estany
	Web: http://pinux.info || Blog: http://pintant.cat
	GPG Key 0x8CD5C157


More information about the dovecot mailing list