summaryrefslogtreecommitdiff
path: root/.local/bin/smail
blob: 869beb884081a8034ce5b427092559654c3f46e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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