0

If you use e.g. Solaris without additional installed software to send MIME mails: how can you send mails with MIME attachments with standard command line tools?

1 Answer 1

2

You can use the following fragment in a shell script. This is admittedly a very ugly hack, so do use this only for uncritical things. I think it is possible that it adds a byte or two at the end of the file, but otherwise it seems to work fine.

mail ${mailinglist} << END_MAIL
To: ${mailinglist}
From: ${mailsender}
Subject: ${subject}
Content-Type: multipart/mixed; boundary="_NextPart_"
Content-Type: text/plain; charset=us-ascii

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_

Hallo,

here is whatever.zip.

--_NextPart_
Content-Type: application/x-zip-compressed;
 name="whatever.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="whatever.zip"

`
uuencode whatever.zip whatever.zip | sed -e 's/^end$/~~~/' | tail +2 | cut -c 2- | 
tr ' !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\133\134\135^_' \
 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | 
sed -e 's/^~~$/==/' 
`

--_NextPart_--

END_MAIL

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .