You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mblaze/mcomp

52 lines
686 B
Bash

#!/bin/sh
# mcomp [TO] - compose mail
i=0
while [ -f "snd.$i" ]; do
i=$((i+1))
done
draft="snd.$i"
{
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
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=q
fi
;;
*)
echo -n "What now? ([s]end, [c]ancel, [e]dit) "
read -r c
;;
esac
done