#!/bin/sh -e
# mimeit - mail base64-encoded stdin
#    with content-type $1
#    to recipient $2
#    with subject $3
# All other arguments are passed on to splitmail 

if [ $# -lt 3 ]; then
	echo "Usage: $0 <content-type> <recipient> <subject> [splitmail-options]" >&2
	exit 1
fi

ct="$1"
to="$2"
sub="$3"

shift
shift
shift

( echo Mime-Version: 1.0 ; \
  echo Content-type: "$ct" ; \
  echo To: "$to" ; \
  echo Subject: "$sub" ; \
  echo Content-Transfer-Encoding: base64 ;
  echo "" ; \
  mimencode -b ) | splitmail -d $*
