Click to See Complete Forum and Search --> : Smtp


Jacko123
July 10th, 2007, 02:01 AM
Hi guys,
I have a plain text file. I want to encrypt and send this file via mail. I use SMTP to send the file over network. I'm able to send the file in plain text but if I encode and send it, I get some stupid data. I make use of base64 to encode the file. Here is the tags (with data) that I send to mail server.

MIME-Version: 1.0
From: abc@gmail.com
To: xyz@yahoo.com
Subject: Hi
Content-Type: multipart/mixed; boundary=unique-boundary-1

--unique-boundary-1
Content-Type: text/plain
Content-Transfer-Encoding: base64
Content-Disposition: attachment;filename=fileName

8 4 0 6 6 0 0 0 0 5.943 1 0 1
8 0 0 6 23 0 0 0 0 6.289 0.4 0 1
8 0 1 15 0 0 0 0 0 4.557 1 0 1
8 0 1 16 0 0 0 0 0 4.21 0 0 1
8 0 1 17 0 0 0 0 0 1.039 0 0 1
6 4 0 1 1 2 18 0 0 5.943 0.6 0 1
6 2 1 8 8 16 0 0 0 3.864 0.6 0 1
6 2 1 7 7 9 0 0 0 3.518 0.4 0 1
6 2 1 8 10 10 0 0 0 3.171 0.6 0 1
6 2 1 9 9 11 0 0 0 2.825 0.4 0 1
6 2 1 10 12 12 0 0 0 2.478 0.6 0 1
6 2 1 11 11 13 0 0 0 2.079 0.6 0 1
6 2 1 12 14 14 0 0 0 1.732 0.4 0 1
6 2 1 13 13 17 0 0 0 1.386 0.6 0 1
6 0 1 3 16 20 0 0 0 4.557 0.6 2 1
6 0 1 4 7 15 0 0 0 4.21 0.4 1 1
6 0 1 5 14 21 0 0 0 1.039 0.4 1 1
6 0 2 6 19 0 0 0 0 5.596 0.4 0 1
6 0 2 18 20 0 0 0 0 5.25 0.6 0 1
6 0 2 15 19 0 0 0 0 4.903 0.4 0 1
6 0 2 17 22 0 0 0 0 0.6928 0.6 0 1
6 0 2 21 24 0 0 0 0 0.3464 0.4 0 1
6 0 3 2 0 0 0 0 0 6.635 0.6 0 1
6 0 3 22 0 0 0 0 0 0 0.6 0 1

--unique-boundary-1--
.
Is there anything I'm doing wrong.. Please help me to solve the problem.

Thanks

henky@nok.co.id
July 10th, 2007, 02:18 AM
It seems that your encoding was wrong. Did you program encode
base64 correctly?

Jacko123
July 10th, 2007, 02:27 AM
It seems that your encoding was wrong. Did you program encode
base64 correctly?

You mean to say I have to first encode the data with base64, then send the encoded data over network. Will Content-Transfer-Encoding: base64 not encode the data and send it. I mean I have a plain text file, when I write Content-Transfer-Encoding: base64, will not the plain text data be encoded and sent???

Hope I'm clear
Thanks

henky@nok.co.id
July 10th, 2007, 02:42 AM
You mean to say I have to first encode the data with base64, then send the encoded data over network. Will Content-Transfer-Encoding: base64 not encode the data and send it. I mean I have a plain text file, when I write Content-Transfer-Encoding: base64, will not the plain text data be encoded and sent???

Hope I'm clear
Thanks
Yes that's right. You need to encode the file first before take it into
attachment block.
So, the diagram should be:

Sending email:
File --> (Encoding base64) --> encoded file

Receiving email:
encoded file --> (Decoding base64) --> File

The file can be text or binary.

Jacko123
July 10th, 2007, 02:56 AM
Ok, I'll try the code and see if it works.

I was not encoding the file and thought Content-Transfer-Encoding: base64 would take care of encoding the file and send it.

Will let you know the status.
Thanks

Jacko123
July 10th, 2007, 03:40 AM
Ok, with base64 it works...
I have a doubt,
1) Why I have to use only base64 or uuencode algorithm to encode and decode???
2) Cant I write my own algorithm to encode the file and then send it across network, instread of using base64....

Actually I have written my encoding algorithm to encode the file, I want to send this encoded file across file. How can I do that??

henky@nok.co.id
July 10th, 2007, 06:09 AM
Ok, with base64 it works...
I have a doubt,
1) Why I have to use only base64 or uuencode algorithm to encode and decode???
2) Cant I write my own algorithm to encode the file and then send it across network, instread of using base64....

Actually I have written my encoding algorithm to encode the file, I want to send this encoded file across file. How can I do that??
1) This is MIME (Multipurpose Internet Mail Extension) specification to
standardize email transmission. There is history why MIME states only
base64 and uuencode.

2) SMTP allows what ever encoded file as long as it is not binary
(must be ASCII). But you will loose compatibilities with other mailers.
That's why IETF (Internet Engineering Task Force) made this standard.

Jacko123
July 10th, 2007, 08:15 AM
1) This is MIME (Multipurpose Internet Mail Extension) specification to
standardize email transmission. There is history why MIME states only
base64 and uuencode.

2) SMTP allows what ever encoded file as long as it is not binary
(must be ASCII). But you will loose compatibilities with other mailers.
That's why IETF (Internet Engineering Task Force) made this standard.

Ok, If that is the case then how do think lotus notes or other mailing list works. I use lotus notes to send and receive the mails. When I attach the same file and send, the receiver gets the file without data being modified. I want the same functionality I have an encrypted file, I want to attach the file and send such that the file doest get modified.

Thanks

henky@nok.co.id
July 10th, 2007, 10:09 PM
Ok, If that is the case then how do think lotus notes or other mailing list works. I use lotus notes to send and receive the mails. When I attach the same file and send, the receiver gets the file without data being modified. I want the same functionality I have an encrypted file, I want to attach the file and send such that the file doest get modified.

Thanks
Internally lotus notes will encode attached file before sending email.
You can test sending email using lotus notes and check the source
email from your POP/IMAP server. You'll find what i tell you.