mirror of
https://github.com/leahneukirchen/mblaze
synced 2024-11-17 21:25:50 +00:00
88 lines
1.4 KiB
Bash
Executable File
88 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# mcomp [TO] - compose mail
|
|
|
|
i=0
|
|
while [ -f "snd.$i" ]; do
|
|
i=$((i+1))
|
|
done
|
|
draft="snd.$i"
|
|
|
|
{
|
|
case "$0" in
|
|
*mcomp*)
|
|
echo -n "To: $1"
|
|
[ "$#" -gt 1 ] && shift
|
|
for rcpt; do
|
|
echo -n ", $rcpt"
|
|
done
|
|
echo
|
|
echo "Cc: "
|
|
echo "Bcc: "
|
|
echo "Subject: "
|
|
cat ~/.santoku/headers 2>/dev/null
|
|
echo
|
|
echo
|
|
;;
|
|
*mrepl*)
|
|
[ "$#" -eq 0 ] && set -- .
|
|
# XXX reply-all
|
|
echo "To: $(mhdr -from "$1")"
|
|
echo "Cc: "
|
|
echo "Bcc: "
|
|
s=$(mhdr -subject "$1")
|
|
os=
|
|
while [ "$os" != "$s" ]; do
|
|
os=$s
|
|
s=${s% }
|
|
s=${s%[Rr][Ee]:}
|
|
s=${s%[Aa][Ww]:}
|
|
s=${s%[Ff][Ww][Dd]:}
|
|
done
|
|
echo "Subject: Re: $s"
|
|
cat ~/.santoku/headers 2>/dev/null
|
|
echo -n "References:"
|
|
{
|
|
mhdr -references "$1"
|
|
mhdr -message-id "$1"
|
|
} | sed 's/^[^<]*//g;s/[^>]*$//g;s/>[^<]*</>\n</g' |
|
|
uniq | sed 's/^/ /'
|
|
echo "In-Reply-To: $(mhdr -message-id "$1")"
|
|
echo
|
|
|
|
echo "$(mhdr -from "$1") wrote:"
|
|
mshow -R "$1" |
|
|
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' |
|
|
sed 's/^/> /'
|
|
echo
|
|
esac
|
|
|
|
if [ -f ~/.signature ]; then
|
|
printf '%s\n' '-- '
|
|
cat ~/.signature
|
|
fi
|
|
} >$draft
|
|
|
|
c=e
|
|
while :; do
|
|
case "$c" in
|
|
s|send)
|
|
sendmail -t <$draft && rm $draft
|
|
exit $?
|
|
;;
|
|
c|cancel)
|
|
echo "mcomp: cancelled draft $draft"
|
|
exit 1
|
|
;;
|
|
e|edit)
|
|
c=
|
|
if ! ${EDITOR:-vi} $draft; then
|
|
c=c
|
|
fi
|
|
;;
|
|
*)
|
|
echo -n "What now? ([s]end, [c]ancel, [e]dit) "
|
|
read -r c
|
|
;;
|
|
esac
|
|
done
|