[PATCH] Pass relevant maildir filenames to newmail_hook
dev at gwn.wtf
Thu Jul 18 11:34:46 BST 2019
So that the hook can implement advanced features that acts on the
newly synced mail content.
Greetings. I was looking for a way to automatically get the
content of the newly synced emails after I run offlineimap.
Initially I tried to parse the output of `offlineimap -u
machineui` to generate the relevant maildir filenames, but I could
not accomplish that.
So here is an example solution using the "newmail_hook"
I implemented this patch just to get the idea across, I'd be very
happy to hear alternative solutions that doesn't require patching
Also please note that this patch is not backwards compatible as it
causes "newmail_hook" lambdas with no arguments trigger
offlineimap/folder/Base.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 5f287fa..f1376b7 100644
@@ -947,8 +947,18 @@ class BaseFolder(object):
# Execute new mail hook if we have new mail.
+ dstfolder_fullname = dstfolder.getfullname()
+ newmail_filenames = [
+ for uid in copylist
if self.newmail_hook != None:
def __syncmessagesto_delete(self, dstfolder, statusfolder):
"""Pass 2: Remove locally deleted messages on dst.
More information about the OfflineIMAP-project