Sending an Attachment with Telnet

ianmclachlan
ianmclachlan used Ask the Experts™
on
Hi Guys,

I am trying to send  attachments through telnet to test my mail server.  I don't have an issue compiling general emails, just attachments. I have got a couple of questions that I hope maybe someone could answer.

Does anyone know of a GUI (telnet/email client thingy) that I could use to telnet into port 25 then send emails with or without attachments?

or

know of a tutorial/step by step guide on this.  I have searched the web and my understanding is that the file as to be encoded in MIMe, BinHEx or UUencode.  

I assume that you need encoding software to convert the file to the required format then paste it under the DATA entry on the telnet session with the appropriate headers etc...  Its the exact syntax or method that I am not too sure about.  Also, the term BASE64 gets banded about alot with regards to encoding which is slightly beyond me.  

Option one would be much better, however, I am not lazy and would be more than happy to learn / read more about how to do to manually  if such documentation exists.

Many thanks


IM



Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I guess the question is why. An attachment is just a section of text in the email that was encoded from the binary file. It's like any other text. The email client is the thing that decodes it.

Author

Commented:
The background behind it is I have a dev environment and I am testing the email policies such as exe, jpg etc.... before applying it to the live environment,  I could setup a client, however, I think telnet fits the bill (once I learn how to use it with attachments). This will also be useful for other servers in future as telnet has been one of my most used apps in email troubleshooting.

IM

Author

Commented:
Hi Guys,

I have taken a file sample.txt and encoded it to BASE64.  This produced a lot of text which I assume will be pasted to the DATA section.  So really the question surrounds headers (MINE) etc...  Anyone know how I should structure this?  Any examples?

Thanks

IM
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Here is how I am forming my message:

helo test
mail from: joebloggs@joebloggs.co.uk
rcpt to: iamhere@mydomain.com
data

from: joebloggs@joebloggs.co.uk
to: iamhere@mydomain.com
subject: hello

hello,

Blah, blah, blah

bye

MIME-Version: 1.0
Content-Type: image/gif
Content-Transfer-Encoding:base64

AAAAAAsAAABIAAAAIA8AAAAAAAAgAgAAAQAAIAcAAAB/+/8fKAAAABwAAAB/+/8fFqqQfy2BLUKd8GfV2VzRhrgCAAAAAAAAMIIPHAYJKoZIhvcNAQcCoIIPDTCCDwkCAQExDjAMBggqhkiG9w0CBQUAMIICMwYJKoZIhvcNAQcBoIICJASCAiABEAgZCB5b3VyIEluc3RpdHV0ZS4gUGxlYXNlDQpyZWNlaXZlIHRoZSBhdHRhY2hlZCBmaW etc.....

Can anyone see anything wrong with it?  File was encoded BASE64.


.
You need to tell the server you're going to send it a multipart MIME message first, otherwise that MIME-VERSION statement you're giving it is just another line of text..

I found this site which describes exactly what you're trying to do:
http://www.hochfeiler.it/alvise/smtp.htm

but basically here's the format they show:

From: <donald.duck@disney.com> CRLF
To: <mickey.mouse@disney.com> CRLF
Subject: foobar CRLF
MIME-Version: 1.0 CRLF
Content-Type: multipart/mixed; CRLF
 boundary= "KkK170891tpbkKk__FV_KKKkkkjjwq" CRLF
CRLF
--KkK170891tpbkKk__FV_KKKkkkjjwq CRLF
Content-Type: text/plain; charset=US-ASCII CRLF
CRLF
here goes the text message CRLF
CRLF
--KkK170891tpbkKk__FV_KKKkkkjjwq CRLF
Content-Type: application/octet-stream CRLF
Content-Transfer-Encoding: base64 CRLF
Content-Disposition: attachment; CRLF
 filename= "suggested name of the attachment" CRLF
CRLF
here goes the Base64 encoded attachment CRLF
--KkK170891tpbkKk__FV_KKKkkkjjwq-- CRLF
CRLF.CRLF

You can also refer to this:
http://en.wikipedia.org/wiki/MIME
which has links to the several RFCs which together define MIME..
-Steve

Author

Commented:
Excellent

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial