From 92b93a93342d7b06acd778c638d18f1454115f9f Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Sat, 26 Nov 2022 22:01:09 -0500 Subject: [PATCH] aerc/notmuch items - [bin] Add the aerc-notmuch-send script - [bin] Updates to the mail-sync.sh script. We run offlineimap once, and we add a bunch of tag-for-deletion targets. --- bin/aerc-notmuch-send | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/aerc-notmuch-send diff --git a/bin/aerc-notmuch-send b/bin/aerc-notmuch-send new file mode 100755 index 0000000..82ac350 --- /dev/null +++ b/bin/aerc-notmuch-send @@ -0,0 +1,29 @@ +#!/bin/sh +# XXX: This does not handle encryption + +# ensure the script ends whenever a command exits with non-zero status +set -e + +EMAIL=$(mktemp --suffix=.eml /tmp/XXXXXX) +clean_up() { + rm -f "$EMAIL" +} + +# The account to be used is given as the first argument of this script +account=$1 +shift + +# ensure clean_up() is called when we exit abnormally +trap 'clean_up' 0 1 2 3 15 + +# of script gets the email, we save temporarily for using it twice +cat >"$EMAIL" + +# First try to send the email, as it can cause more problems (i.e., connection) +# `set -e` prevents the mail from entering the database in case this fails. +# msmtp could be called with args from aerc, but --read-recipients already does the job +msmtp --account="$account" --read-recipients --read-envelope-from <"$EMAIL" + +# assumes all maildir accounts are configured with a 'sent' directory +# also make sure to tag it correctly +notmuch insert --folder=Sent -inbox -unread +sent <"$EMAIL"