Mailing attachments

Brian Cluff plug-discuss@lists.PLUG.phoenix.az.us
Tue, 4 Sep 2001 16:29:27 -0700


> can you not just do it the old redirected way?
>
> mail -s "my log file" my@email.address < /var/log/messages

Thats works great for text files, but if you are wanting to mail someone an
image if you just redirect it to mail, you get a message full of spooge, and
you also can't be sure that it would even end up in your mailbox the same
due to some servers striping 8 bit characters down to 7 bit.

Anyway, this seems like a common enough issue there is probably an easier
way to do it, but you could always build the e-mail by hand and use
mimencode to get a binary down to something palatable to the e-mail program.
Below is a raw format for how to do it by hand using an attached jpeg as an
example.  The text within the boundary= header can be anything you want.
Just make it unique so that it doesn't have a possibility of occuring in
your message.

Brian Cluff

.
normal mail headers... From To Whatever.....
.
.
MIME-Version: 1.0
Content-Type: multipart/mixed
     boundary="----_=_NextPart_000_01C12156.B139BDE0"
Status: RO

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C12156.B139BDE0
Content-Type: text/plain;
 charset="iso-8859-1"

.
.
A text message that goes along with your binary data
.
.

------_=_NextPart_000_01C12156.B139BDE0
Content-Type: image/jpeg;
    name="Tape.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
    filename="Tape.jpg"
.
.
Your binary encoded date that mimencode spits out
.
.
------_=_NextPart_000_01C12156.B139BDE0--