Required Setups
Packages
Message
(use-package message
:custom
(message-directory (expand-file-name ".mail" (getenv "HOME")))
(message-sendmail-envelope-from 'header))
Notes:
message-directory
should reflects the root directory for mail.
sendmail
(use-package sendmail
:custom
(mail-specify-envelope-from t)
(mail-envelope-from 'header)
(send-mail-function 'sendmail-send-it)
(sendmail-program (executable-find "msmtp")))
Notes:
sendmail-program
should point to the full path.
Hooks
Post-new
#!/usr/bin/env bash
_AFEW=$(command -v afew)
newcount=$(notmuch count tag:new)
summary="Notmuch: ${newcount} new message"
[ -n "${_AFEW}" ] &&
"${_AFEW}" --tag --new -vv
if [ $newcount -gt 1 ]; then summary="${summary}s"; fi
if [ $newcount -gt 0 ]; then detail="$(notmuch search --output=summary --format=json tag:new | sed -e 's/.*authors": "//;s/|[^"]*"/"/;s/", "subject": "/ : /;s/".*//')"; fi
notmuch tag -new -- tag:new
# See the notmuch pre-hook for DISPLAY thoughts
# Desktop notifications
if [ $newcount -gt 0 ]; then logger -t notmuch "calling notify-send '$summary' '$detail'" && notify-send -i /usr/share/icons/Papirus/symbolic/actions/mail-message-new-symbolic.svg "$summary" "$detail"; fi
# Stop the astroid spinner; this will refresh the UI
[[ "$(pgrep astroid)" != "" ]] && logger -t notmuch "Astroid polling stop requested during post-new hook" && astroid --stop-polling 2>&1 >/dev/null
[ "$(command -v notifymuch)" ] && notifymuch
exit 0
Pre-new
#!/usr/bin/env bash
[[ -x $(which offlineimap) ]] && offlineimap -s
[[ "$(pgrep astroid)" != "" ]] && logger -t notmuch "Astroid polling start requested during pre-new hook" && astroid --start-polling 2>&1 >/dev/null
# Ensure that this script exits with success, otherwise notmuch will fail out.
exit 0