Subject: Re: How do you do MIME Attachments?

From: Jason Haar <[email-masked]>
Date: Mon, 13 Mar 1995 14:54:09 GMT

On Mar 12,  9:06pm, Steve Medin wrote:
> Subject: How do you do MIME Attachments?
> I have an autoreply recipe that cats ASCII files into its replies.  I'd
like
> to reply with attachments so that I can send files using formats native to
> PCs and Macs.
>
> I don't see how to attach files using formail.  Can formail or a substitute
> make mails with attached files, or can it only make attachments in the body
> that have been uuencoded?
>-- End of excerpt from Steve Medin

MIME is a doddle to do. Just whack some extra headers in the right place and
you're away laughing.

Here's a shell script that'll do it for you - call as "makemime <filename> "

(BTW, I just wrote it in response to this message - it may not work, but it
should point you in the right direction. Of course you'll need the base64
encoder from metamail to do the encoding.)

Cheers

Jason

---
#!/bin/sh
APP="application/octet-stream"

if [ "$1" = "" ]; then
	echo "Error: $0 <filename> [application]"
	exit
elif [ "$2" != "" ]; then
	APP="$2"
fi

BOUNDARY="jasons-mime-script-$$"
(cat<<EOF
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="$BOUNDARY"

This is a MIME message. Your mailer doesn't appear to understand MIME format.
You will need to read this message with a MIME mailer in order to appreciate
its full beauty.

--$BOUNDARY
Content-Type: $APP; name="$1"
Content-Transfer-Encoding: base64

EOF
mmencode $1
cat<<EOF
--$BOUNDARY--
EOF
)

---

Call as makemime filename|sendmail -oi address