Subject: Two files for you
To: [email-masked]

mimesend

I like MIME.

If you also like MIME perhaps you will find this script interesting.

It runs under Linux (bash).

mimesend allows you to build sophisticated and funny MIME messages.
It allows recursion, so you can put MIME blocks inside others with a single command.

Download mimesend v 1.0 .

Unpack the tarball.

Execute (as root) m-install to install it.

Execute man mimesend to read how to use it.

Bugs to me.

I like SMIME.

mimesend also has powerful support for SMIME.

You need to install openssl
(configure and make procedure) before running m-install.

smimedec is a simple script that tries to decrypt and verify
signatures on SMIME messages.

Here you can see some mimesend examples:

MIME Examples.

To build, but do not send, a mail with two files:

mimesend -o -\
-t [email-masked] \
-i -e base64 -m image/gif -f sound2.gif \
-i -e base64 -m text/html -f mimesend.html \
-s 'Two files for you'

This command sends a mail for every directory inside the first level of the
current dir, with all the files contained in it:

for f in $(find * -type d -maxdepth 0 -print); do
mimesend \
-t [email-masked] \
-f $f \
-j "Files on $f"
done

Now, we send all the files in a single mail, separating them with
a block containing his name:

eval mimesend \
-t [email-masked] \
-j \"All the files/dirs follows\" \
$(for f in $(find * -type d -maxdepth 0 -print); do
echo " -r '-j \"----- Files on $f -----\" -l $f'"
done)

or simply:

eval mimesend \
-t [email-masked] \
-j \"All the files/dirs follows\" \
$(for f in $(find * -type d -maxdepth 0 -print); do
echo "-l $f"
done)

or more simple and nice:

mimesend \
-t [email-masked] \
-j "All the files/dirs follows" \
-L "$(find * -type d -maxdepth 0 -print)"

Several nice examples:

mimesend -r "-r '-r \"-r '\''-j message'\''\"'" -t [email-masked]
mimesend -r "-j m1 -r '-j m2 -r \"-j m3 -r '\''-j m4'\''\"'" -t [email-masked]
mimesend -r "-j m1 -r '-j m2 \
-R\" -F me@you -s hello -t you@me \
-j m31 -r'\'' -j m32'\''\"'" -t [email-masked]

Spending the time:

x=""; r1=""; r2=""
for f in 1 2 3 4 5 6 7 8 9; do
r1="$r1 -r $x\" -j m$f "
r2="$x\"$r2"
x="$x$x\\"
done

eval mimesend -n $r1$r2

A little more:

x=""; r1=""; r2=""
y="\\"
for f in a b c d e f g h i; do
r1="$r1 -r $x\" -j $y\"Block $f$y\" "
r2="$x\"$r2"
x=$y
y="$y$y\\"
done

eval mimesend -n $r1$r2

An exotic example:

mimesend -o - <<-EoF -a -j "This is plain text" -f -
<html>
This is HTML text
EoF

A better example (a nice feature):

mimesend -j '<html>This is always' -f '<html>This is true HTML' \
-j 'text/plain' -f '<html>This is another block' -o -

Multiline:

mimesend -j 'Attached is the HTML text' \
-j 'You should not be reading this' -a \
-f '<html>
This is autodetected HTML text.
<ul><li>An item.
<li>Another
</ul>' -t [email-masked]

Embeding objects using multipart/related:

mimesend -x -f '<html>
<body background="%%2%%">
<hr><center><img src="%%3%%"></center>
This is a simple html page embeded in mail.
<br><br><br><br><br>
' -f nisubg.gif -f nisu.gif -t [email-masked]

Another example:

(echo '<html>'
c=2
for f in $(find -name \*.gif) ; do
echo "Image #$[c-1](${f##*/})<img src=\"%%$c%%\"><br>"
c=$[c+1]
done
) | mimesend -x -f - -f \*.gif -t [email-masked]

SMIME examples.

We send a two-line message, the file design1.gif, and two MIME blocks:

the first contains two files, page.html and design2.gif
and is cyphered with the certificate contained in dest.pem,
using weak cryptography for compatibility.

the second block is a forwarded mail signed with the key and
including the certificate taken form file demo-invalid.pem;
the forwarded mail includes the image design3.gif and the
preformat MIME block stored in the file preformatedMIME.dat,
perhaps the result of another execution of mimesend.

mimesend \
-s "Test level 2 anidation" \
-t [email-masked] \
-j "First line." \
-F "I am <[email-masked]>" \
-m image/gif -f design1.gif \
-r "-m -D 'Another design' -f design2.gif \
-f page.html \
-C dest.pem -E des \
" \
-R "-j this -j 'This is a simple mail.' \
-f design3.gif \
-d preformatedMIME.dat \
-S demo-invalid.pem -s \"Signed mail inside\" \
" \
-j "Second line of the same block."

If you have all your foreign certs in the directory 'email_certs', you can send
an encrypted mail to a lot of addresses, that you have stored in a file:

mimesend -t "$(cat people)" -C email_certs -C my_cert -j "small message"

but only a big message will be sent, as all recipes are codified into the pkcs7
structure. The alternative:

mimesend -T -t "$(cat people)" -C email_certs -C my_cert -j "small message"

sends one different really small message for every address. See note about -C .

Suposse that you have a cert for [email-masked] but not for [email-masked].
This command gives a warning, that you should consider:

mimesend -f file1 -r '-t [email-masked] -f file2 -C somedir' -t [email-masked]

For more examples, see the (S)MIME examples (in spanish).