#!/bin/sh set -e tmp=`mktemp` trap "rm -f $tmp" EXIT addr="`tee $tmp | mhdr -h from - | sed -E '/.*<.*>$/s/.*<(.*)>$/\1/'`" mbox="$MAILDIR/$addr/Sent" if msmtp -t --read-envelope-from <$tmp then mgenmid \ | sed 's/^/Message-Id: /' \ | cat - $tmp \ | mmime \ | mdeliver -cv "$mbox" \ | xargs chronic mflag -S fi