home · contact · privacy
Improve mail setup.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 16 May 2019 21:06:44 +0000 (23:06 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 16 May 2019 21:06:44 +0000 (23:06 +0200)
buster/home_files/user_eeepc/.mbsyncrc
buster/home_files/user_eeepc/.notmuch-config [new file with mode: 0644]
buster/home_files/user_eeepc/mail_sync.sh [new file with mode: 0755]

index cab35a77e98a7f61734f127c6db70fb174d0a5e6..d3d3d88aec7457dfe7b596d9c86069395e301292 100644 (file)
@@ -24,3 +24,5 @@ Patterns *
 Create Both
 # Save the synchronization state files in the relevant directory
 SyncState *
+# If a mail is marked T ("Trashed") or deleted, remove it for real everywhere
+Expunge Both
diff --git a/buster/home_files/user_eeepc/.notmuch-config b/buster/home_files/user_eeepc/.notmuch-config
new file mode 100644 (file)
index 0000000..230bbe3
--- /dev/null
@@ -0,0 +1,4 @@
+[database]
+path=/home/plom/mail
+[search]
+exclude_tags=deleted;spam;
diff --git a/buster/home_files/user_eeepc/mail_sync.sh b/buster/home_files/user_eeepc/mail_sync.sh
new file mode 100755 (executable)
index 0000000..d20690d
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -e
+
+# Ensure all "dir:*"-tagged mails are in proper directories.
+basedir="/home/plom/test_mbsync/maildir/"
+for tag in $(notmuch search --output=tags '*'); do
+    if [ ! $(echo "${tag}" | cut -c-4) = "dir:" ]; then
+        continue
+    fi
+    target_dir="${basedir}"$(echo "${tag}" | cut -c5-)"/cur/"
+    for f in $(notmuch search --output=files tag:"${tag}"); do
+         new_name=$(basename "${f}" | sed -e 's/,U=[0-9]*//')
+         target_path="${target_dir}${new_name}"
+         if [ ! "${target_path}" = "${f}" ]; then
+             echo "Moving ${f} to ${target_path}."
+             mv "${f}" "${target_path}"
+         fi
+    done
+done
+
+# Remove all "deleted"-tagged files from maildirs.
+notmuch search --output=files tag:deleted | while read f; do
+    echo "Deleting ${f}"
+    rm "${f}"
+done
+
+# Sync changes back to server and update notmuch index.
+mbsync -a
+notmuch new