From: martin f. krafft Date: Mon, 14 Jun 2010 10:02:20 +0000 (+0200) Subject: migrate check for local rcpts to sendmail checks X-Git-Url: https://git.madduck.net/etc/mutt.git/commitdiff_plain/6c2eab948174ee2e6dbef8aa134a235b06c83193?ds=sidebyside;hp=063bbf05f6c593a47a8ddef095ddfb63ef2dcea5 migrate check for local rcpts to sendmail checks --- diff --git a/.mutt/hooks b/.mutt/hooks index 4613eda..4c809eb 100644 --- a/.mutt/hooks +++ b/.mutt/hooks @@ -1,9 +1,6 @@ save-hook . =store send2-hook '~C notyet' "set sendmail='~/.mutt/error 1 I will not send this draft yet!'" -# this next works in combination with $use_domain to ensure I don't send -# without expanding aliases: -send2-hook '~C @$hostname' "set sendmail='~/.mutt/error 1 Check your recipients!'" send2-hook '~C @packages\.qa\.debian\.org' 'my_hdr X-PTS-Approved: please' diff --git a/.mutt/sendmail-checks.d/no-local-recipients b/.mutt/sendmail-checks.d/no-local-recipients new file mode 100755 index 0000000..fa8de41 --- /dev/null +++ b/.mutt/sendmail-checks.d/no-local-recipients @@ -0,0 +1,28 @@ +#!/bin/sh +# +# no-local-recipients – prevent messages to local recipients from being sent +# +# messages with recipients like foo@$HOSTNAME are an indication that mutt has +# not expanded the aliases and thus appended $hostname (cf. $use_domain). In +# my use-case, that's a reason not to send a message. +# +# Copyright © 2010 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -eu + +shift # $1 is the tmpfile, we don't need that + +HOSTNAME=$(hostname --fqdn) + +ret=0 +for r in $@; do + case "$r" in + (*@${HOSTNAME}*) + echo >&2 "E: $r seems to be a local recipient, hence I won't send." + ret=1 + ;; + esac +done + +exit $ret