diff options
author | Samuel Fadel <samuel@nihil.ws> | 2022-03-19 11:29:48 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-03-20 10:04:25 +0100 |
commit | 9c7b5e258047f4cc94a8f25a0184736f4a9eba06 (patch) | |
tree | d68683bb3bd59365d22d3d9891bc182de7f522f8 | |
parent | df9dabb9aa332011c7ed49518736f4d1871afb99 (diff) | |
download | aerc-9c7b5e258047f4cc94a8f25a0184736f4a9eba06.tar.gz aerc-9c7b5e258047f4cc94a8f25a0184736f4a9eba06.zip |
wiki/configuration: copy-to emulation with notmuch
This documents how to overcome the limitation of copy-to not being
supported by the notmuch backend. It suggests a script and how to set up
aerc accordingly to use it.
Signed-off-by: Samuel Fadel <samuel@nihil.ws>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | configurations/index.md | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/configurations/index.md b/configurations/index.md index d0870aeb..b1c4f72e 100644 --- a/configurations/index.md +++ b/configurations/index.md @@ -17,3 +17,62 @@ text/plain=awk -f ~/.config/aerc/filters/custom-colorize ``` - [solarized by Shaleen Jain](https://lists.sr.ht/~rjarry/aerc-devel/patches/30119#%3C20220310045758.228592-1-shaleen@jain.sh%3E+filters/colorize) + +# Emulating copy-to for the notmuch backend + +Currently, the notmuch backend does not support the `copy-to` setting in +`accounts.conf`. + +One way to work around this is to leverage `notmuch insert`. It works by +inserting the email being sent in the notmuch database and the maildir backing +it, which can then be synchronized to the remote IMAP server using your +favorite IMAP synchronization software. + +The following script illustrates how this can be done. Note that it assumes your +setup uses a directory structure within your main notmuch maildir which consists +of: + +- `$account/sent` for the Sent Emails folder +- `$account` is also the account name in [msmtp](https://marlam.de/msmtp/) + +```shell +#!/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 + +# <stdin> 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=$account/sent -inbox -unread +sent <$EMAIL +``` + +If you call this script `aerc-notmuch-send`, the following can be set in +`accounts.conf` to ensure your emails are copied to your sent folder: + +```ini +[myaccount] +from = My Name <my@email> +source = notmuch://YOUR_MAILDIR_PATH/ +outgoing = /path/to/aerc-notmuch-send myaccount +``` |