Send an attachment via email

It is possible to use telnet to send an email. This is even quite straightforward.
The idea is to start a telnet session with: telnet mail.wxs.nl 25 (or something alike that contains an email server to which one has connection.

One could then enter to indicate the sender and receiver of an email:

helo mail.wxs.nl
mail from: tom.vanmaanen@wxs.nl
rcpt to: tom.vanmaanen@wxs.nl

The actual content of the email is then provided by:

data
Subject: Onzin van Tom
MIME-Version: 1.0 
Content-Type: multipart/mixed; 
 boundary= "KkK170891tpbkKk__FV_KKKkkkjjwq" 

--KkK170891tpbkKk__FV_KKKkkkjjwq 
Content-Type: text/plain; charset=US-ASCII 

Dit is mijn boodschap

One finishes with an empty line and a dot:


.

All commands and the actual text is sent in plain text. It is human readable.
This makes it understandable that an attachment which is in binary format must be translated into plain text before it can be sent. Let us take as example an Access file (a.mdb), that must be translated into plain text. This will look like:

--KkK170891tpbkKk__FV_KKKkkkjjwq 
MIME-Version: 1.0
Content-Description: "Base64 encode of a.mdb by Wincode 2.7.3"
Content-Type: application/msaccess; name="a.mdb"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename="a.mdb"

AAEAAFN0YW5kYXJkIEpldCBEQgABAAAAtW4DYmAJwlXpqWdyQD8AnH6fkP+FmjHFebrtMLzfzJ1j2eTDn0b7irxOmGXsN0PanPrYwCjmDSiKYEoKezbr7N+xaWoTQ9ExsTMq/3lbjCt8KqPgfJkIH5j9DJFyW7X9g2ZflfjQiSSFZ8YfJ0TS7s9l7f8Hx0aheBYM7ektYtRUBgAANC4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

...

--KkK170891tpbkKk__FV_KKKkkkjjwq-- 

A full example can be found here: ExampleEmail.

One may question how the encoding can be accomplished. To do so, I found a set of useful websites (like http://www.opinionatedgeek.com/dotnet/tools/base64encode/ ) in which you may upload the binary file and one may get it encoded back. This can then be included in the mail session.

Door tom