#!/bin/sh - # # $Id: sendmime,v 1.1 1999/10/04 02:58:23 dgregor Exp $ # # # Copyright (c) 1997-1999 Daniel J. Gregor, Jr., All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Daniel J. Gregor, Jr. # 4. The name of Daniel J. Gregor, Jr. may not be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY DANIEL J. GREGOR, JR. ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DANIEL J. GREGOR, JR. BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Notes: # - grab and install the base64 program from http://www.fourmilab.ch/ somewhere # - you may need to adjust the sendmail variable. # Where's our good friend, Sendmail? sendmail=/usr/sbin/sendmail #sendmail=/usr/lib/sendmail basename=`basename $0` die(){ exitval=1 case "$1" in -e*) if [ $# -ge 2 ] then shift exitval=$1 shift fi ;; --) shift ;; esac echo "$basename: $@" >&2 exit $exitval } usage="$basename: usage:\n\t$basename name MIME-type sender recipient subject" while getopts h c do case $c in h|\?) die $usage exit 1 ;; esac done shift `expr $OPTIND - 1` if [ $# -ne 5 ]; then die "Incorrect number of arguments. Use \"-h\" for help" fi name="$1"; shift mimetype="$1"; shift sender="$1"; shift recipient="$1"; shift subject="$1"; shift ( echo "From: $sender\nTo: $recipient\nSubject: $subject\nMIME-Version: 1.0\nContent-Type: $mimetype; name=\"$name\"\nContent-Transfer-Encoding: base64\n\n" ; base64 -e ) | $sendmail -t