summaryrefslogtreecommitdiff
path: root/.local/bin/smail
blob: a51476a63b7285ebc1e3b07a921f25736477e428 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

set -e

tmp=`mktemp`
trap "rm -f $tmp" EXIT

cat - >$tmp
addr="`mhdr -h from $tmp | sed -E '/.*<.*>$/s/.*<(.*)>$/\1/'`"
mbox="$MAILDIR/$addr/Sent"

msmtp -t --read-envelope-from <$tmp \
	&& {
		mgenmid \
		| sed 's/^/Message-Id: /' \
		| cat - $tmp \
		| mmime \
		| mdeliver -cv "$mbox" \
		| xargs mflag -S >/dev/null
	}